From 401a9b352dfcee71eb51afe24a422b99dc7244f8 Mon Sep 17 00:00:00 2001 From: kmetin Date: Tue, 7 Nov 2023 21:51:55 +0300 Subject: [PATCH] fix hanging problem when source and target clusters is not running --- base/commands/migration/migration_stages.go | 3 +++ base/commands/migration/start_stages.go | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/base/commands/migration/migration_stages.go b/base/commands/migration/migration_stages.go index 9d176e6f..a5a191e2 100644 --- a/base/commands/migration/migration_stages.go +++ b/base/commands/migration/migration_stages.go @@ -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) { diff --git a/base/commands/migration/start_stages.go b/base/commands/migration/start_stages.go index 4b8179bf..87ed5f67 100644 --- a/base/commands/migration/start_stages.go +++ b/base/commands/migration/start_stages.go @@ -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 @@ -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) @@ -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) {