From dae943e46e008944b388e5b517aa16c96bfcc5a5 Mon Sep 17 00:00:00 2001 From: Kutluhan Metin Date: Wed, 15 Nov 2023 15:21:59 +0300 Subject: [PATCH] fix timeout msg (#435) --- base/commands/migration/common.go | 4 ++++ base/commands/migration/migration_stages.go | 6 +----- base/commands/migration/start_stages.go | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/base/commands/migration/common.go b/base/commands/migration/common.go index 1fdd8701..674f82f9 100644 --- a/base/commands/migration/common.go +++ b/base/commands/migration/common.go @@ -5,12 +5,16 @@ package migration import ( "context" "encoding/json" + "errors" "fmt" "github.com/hazelcast/hazelcast-go-client" "github.com/hazelcast/hazelcast-go-client/serialization" ) +var timeoutErr = errors.New("migration could not be completed: reached timeout while reading status: " + + "please ensure that you are using Hazelcast's migration cluster distribution and your DMT configuration points to that cluster") + type MigrationInProgress struct { MigrationID string `json:"id"` } diff --git a/base/commands/migration/migration_stages.go b/base/commands/migration/migration_stages.go index 03615e42..95e1737f 100644 --- a/base/commands/migration/migration_stages.go +++ b/base/commands/migration/migration_stages.go @@ -22,10 +22,6 @@ import ( "github.com/hazelcast/hazelcast-commandline-client/internal/plug" ) -var timeoutErr = fmt.Errorf("migration could not be completed: reached timeout while reading status: "+ - "please ensure that you are using Hazelcast's migration cluster distribution and your DMT configuration points to that cluster: %w", - context.DeadlineExceeded) - var migrationStatusNotFoundErr = fmt.Errorf("migration status not found") var migrationReportNotFoundErr = "migration report cannot be found: %w" @@ -51,7 +47,7 @@ func createMigrationStages(ctx context.Context, ec plug.ExecContext, ci *hazelca statusReaderLoop: for { if ctx.Err() != nil { - if errors.Is(err, context.DeadlineExceeded) { + if clcerrors.IsTimeout(ctx.Err()) { execErr = timeoutErr break statusReaderLoop } diff --git a/base/commands/migration/start_stages.go b/base/commands/migration/start_stages.go index 87ed5f67..e6c17eb4 100644 --- a/base/commands/migration/start_stages.go +++ b/base/commands/migration/start_stages.go @@ -9,6 +9,7 @@ import ( "time" "github.com/hazelcast/hazelcast-commandline-client/clc/ux/stage" + clcerrors "github.com/hazelcast/hazelcast-commandline-client/errors" "github.com/hazelcast/hazelcast-commandline-client/internal/log" "github.com/hazelcast/hazelcast-commandline-client/internal/plug" "github.com/hazelcast/hazelcast-go-client" @@ -103,6 +104,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 { + if clcerrors.IsTimeout(ctx.Err()) { + return timeoutErr + } return ctx.Err() } status, err := fetchMigrationStatus(ctx, ci, migrationID)