Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions internal/data/dataexport/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ func GetDataExport(ctx context.Context, deName, namespace string, rtClient ctrlr
for _, condition := range deObj.Status.Conditions {
if condition.Type == "Ready" {
if condition.Status != "True" {
return nil, fmt.Errorf("DataExport %s/%s is not Ready", deObj.ObjectMeta.Namespace, deObj.ObjectMeta.Name)
return nil, fmt.Errorf("DataExport %s/%s is not Ready: %s (%s)",
deObj.ObjectMeta.Namespace, deObj.ObjectMeta.Name,
condition.Message, condition.Reason)
}
break
}
Expand All @@ -65,7 +67,7 @@ func GetDataExport(ctx context.Context, deName, namespace string, rtClient ctrlr
return deObj, nil
}

func GetDataExportWithRestart(ctx context.Context, deName, namespace string, rtClient ctrlrtclient.Client) (*v1alpha1.DataExport, error) {
func GetDataExportWithRestart(ctx context.Context, deName, namespace string, rtClient ctrlrtclient.Client, log *slog.Logger) (*v1alpha1.DataExport, error) {
deObj := &v1alpha1.DataExport{}

for i := 0; ; i++ {
Expand Down Expand Up @@ -98,7 +100,9 @@ func GetDataExportWithRestart(ctx context.Context, deName, namespace string, rtC
// check DataExport is Ready
if condition.Type == "Ready" {
if condition.Status != "True" {
returnErr = fmt.Errorf("DataExport %s/%s is not Ready", deObj.ObjectMeta.Namespace, deObj.ObjectMeta.Name)
returnErr = fmt.Errorf("DataExport %s/%s is not Ready: %s (%s)",
deObj.ObjectMeta.Namespace, deObj.ObjectMeta.Name,
condition.Message, condition.Reason)
}
}
}
Expand All @@ -115,6 +119,13 @@ func GetDataExportWithRestart(ctx context.Context, deName, namespace string, rtC
if i > maxRetryAttempts {
return nil, returnErr
}
// Every fifth attempt we output it to the terminal so that the user can see the error.
if i > 0 && i%5 == 0 {
log.Info("Still waiting for DataExport to be ready",
slog.String("name", deName),
slog.String("status", returnErr.Error()),
slog.Int("attempt", i))
}
time.Sleep(time.Second * 3)
}

Expand Down Expand Up @@ -230,7 +241,7 @@ func getExportStatus(ctx context.Context, log *slog.Logger, deName, namespace st
var podURL, volumeMode, internalCAData string

log.Info("Waiting for DataExport to be ready", slog.String("name", deName), slog.String("namespace", namespace))
deObj, err := GetDataExportWithRestart(ctx, deName, namespace, rtClient)
deObj, err := GetDataExportWithRestart(ctx, deName, namespace, rtClient, log)
if err != nil {
return "", "", "", err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/data/dataimport/cmd/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func Run(ctx context.Context, log *slog.Logger, cmd *cobra.Command, args []strin
}
}

podURL, _, subClient, err := util.PrepareUpload(ctx, log, diName, namespace, publish, httpClient)
podURL, _, subClient, err := util.PrepareUpload(ctx, diName, namespace, publish, httpClient, log)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/data/dataimport/cmd/upload/upload_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func Run(ctx context.Context, log *slog.Logger, cmd *cobra.Command, args []strin
}
}

podUrl, _, subClient, err := util.PrepareUpload(ctx, log, diName, namespace, publish, httpClient)
podUrl, _, subClient, err := util.PrepareUpload(ctx, diName, namespace, publish, httpClient, log)
if err != nil {
return err
}
Expand Down
20 changes: 16 additions & 4 deletions internal/data/dataimport/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ func GetDataImport(ctx context.Context, diName, namespace string, rtClient ctrlr
for _, condition := range diObj.Status.Conditions {
if condition.Type == "Ready" {
if condition.Status != "True" {
return nil, fmt.Errorf("DataImport %s/%s is not Ready", diObj.ObjectMeta.Namespace, diObj.ObjectMeta.Name)
return nil, fmt.Errorf("DataImport %s/%s is not Ready: %s (%s)",
diObj.ObjectMeta.Namespace, diObj.ObjectMeta.Name,
condition.Message, condition.Reason)
}
break
}
Expand Down Expand Up @@ -95,6 +97,7 @@ func GetDataImportWithRestart(
ctx context.Context,
diName, namespace string,
rtClient ctrlrtclient.Client,
log *slog.Logger,
) (*v1alpha1.DataImport, error) {
for i := 0; ; i++ {
if err := ctx.Err(); err != nil {
Expand Down Expand Up @@ -131,7 +134,9 @@ func GetDataImportWithRestart(
}
if condition.Type == "Ready" {
if condition.Status != "True" {
notReadyErr = fmt.Errorf("DataImport %s/%s is not Ready", diObj.ObjectMeta.Namespace, diObj.ObjectMeta.Name)
notReadyErr = fmt.Errorf("DataImport %s/%s is not Ready: %s (%s)",
diObj.ObjectMeta.Namespace, diObj.ObjectMeta.Name,
condition.Message, condition.Reason)
}
}
}
Expand All @@ -156,16 +161,23 @@ func GetDataImportWithRestart(
if i > maxRetryAttempts {
return nil, notReadyErr
}
// Every fifth attempt we output it to the terminal so that the user can see the error.
if i > 0 && i%5 == 0 {
log.Info("Still waiting for DataImport to be ready",
slog.String("name", diName),
slog.String("status", notReadyErr.Error()),
slog.Int("attempt", i))
}
time.Sleep(retryInterval * time.Second)
}
}

func PrepareUpload(
ctx context.Context,
_ *slog.Logger,
diName, namespace string,
publish bool,
sClient *safeClient.SafeClient,
log *slog.Logger,
) ( /*url*/ string /*volumeMode*/, string /*subClient*/, *safeClient.SafeClient, error) {
var url, volumeMode string
var subClient *safeClient.SafeClient
Expand All @@ -176,7 +188,7 @@ func PrepareUpload(
return "", "", nil, err
}

diObj, err := GetDataImportWithRestart(ctx, diName, namespace, rtClient)
diObj, err := GetDataImportWithRestart(ctx, diName, namespace, rtClient, log)
if err != nil {
return "", "", nil, err
}
Expand Down