Skip to content

Commit

Permalink
fix hanging problem when source and target clusters is not running
Browse files Browse the repository at this point in the history
  • Loading branch information
kutluhanmetin committed Nov 7, 2023
1 parent beb23e4 commit 401a9b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions base/commands/migration/migration_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ func saveReportToFile(ctx context.Context, ci *hazelcast.ClientInternal, migrati

func WaitForMigrationToBeInProgress(ctx context.Context, ci *hazelcast.ClientInternal, migrationID string) error {
for {
if ctx.Err() != nil {
return ctx.Err()
}
status, err := fetchMigrationStatus(ctx, ci, migrationID)
if err != nil {
if errors.Is(err, migrationStatusNotFoundErr) {
Expand Down
7 changes: 5 additions & 2 deletions base/commands/migration/start_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (st *StartStages) startStage() func(context.Context, stage.Statuser[any]) (
if err = st.startQueue.Put(ctx, cb); err != nil {
return nil, fmt.Errorf("updating start Queue: %w", err)
}
childCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
childCtx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
if err = waitForMigrationToStart(childCtx, st.ci, st.migrationID); err != nil {
return nil, err
Expand All @@ -91,7 +91,7 @@ func (st *StartStages) startStage() func(context.Context, stage.Statuser[any]) (

func (st *StartStages) preCheckStage() func(context.Context, stage.Statuser[any]) (any, error) {
return func(ctx context.Context, status stage.Statuser[any]) (any, error) {
childCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
childCtx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
if err := WaitForMigrationToBeInProgress(childCtx, st.ci, st.migrationID); err != nil {
return nil, fmt.Errorf("waiting for prechecks to complete: %w", err)
Expand All @@ -102,6 +102,9 @@ func (st *StartStages) preCheckStage() func(context.Context, stage.Statuser[any]

func waitForMigrationToStart(ctx context.Context, ci *hazelcast.ClientInternal, migrationID string) error {
for {
if ctx.Err() != nil {
return ctx.Err()
}
status, err := fetchMigrationStatus(ctx, ci, migrationID)
if err != nil {
if errors.Is(err, migrationStatusNotFoundErr) {
Expand Down

0 comments on commit 401a9b3

Please sign in to comment.