Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLC-432]: Fix hanging problem when source and target clusters is not running #428

Merged
merged 1 commit into from
Nov 14, 2023
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
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
Loading