Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kutluhanmetin committed Nov 6, 2023
1 parent 9a153d5 commit 465a2e0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion base/commands/migration/migration_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ var timeoutErr = fmt.Errorf("migration could not be completed: reached timeout w

var migrationStatusNotFoundErr = fmt.Errorf("migration status not found")

var progressMsg = "Migrating %s: %s"

func createMigrationStages(ctx context.Context, ec plug.ExecContext, ci *hazelcast.ClientInternal, migrationID string) ([]stage.Stage[any], error) {
childCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
Expand All @@ -41,7 +43,7 @@ func createMigrationStages(ctx context.Context, ec plug.ExecContext, ci *hazelca
for i, d := range dss {
i := i
stages = append(stages, stage.Stage[any]{
ProgressMsg: fmt.Sprintf("Migrating %s: %s", d.Type, d.Name),
ProgressMsg: fmt.Sprintf(progressMsg, d.Type, d.Name),
SuccessMsg: fmt.Sprintf("Migrated %s: %s", d.Type, d.Name),
FailureMsg: fmt.Sprintf("Failed migrating %s: %s", d.Type, d.Name),
Func: func(ct context.Context, status stage.Statuser[any]) (any, error) {
Expand Down Expand Up @@ -83,6 +85,7 @@ func createMigrationStages(ctx context.Context, ec plug.ExecContext, ci *hazelca
ec.Logger().Error(err)
status.SetText("Unable to calculate remaining duration and progress")
} else {
status.SetText(fmt.Sprintf(progressMsg, d.Type, d.Name))
status.SetProgress(cp)
status.SetRemainingDuration(rt)
}
Expand Down Expand Up @@ -267,6 +270,12 @@ func fetchOverallProgress(ctx context.Context, ci *hazelcast.ClientInternal, mig
if err != nil {
return 0, 0, err
}
if completionPercentage == nil {
return 0, 0, fmt.Errorf("completionPercentage is not available in %s", StatusMapName)
}
if remainingTime == nil {
return 0, 0, fmt.Errorf("remainingTime is not available in %s", StatusMapName)
}
rt, err := strconv.ParseInt(remainingTime.(serialization.JSON).String(), 10, 64)
if err != nil {
return 0, 0, err
Expand Down

0 comments on commit 465a2e0

Please sign in to comment.