Skip to content

Commit

Permalink
fix timeout msg (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
kutluhanmetin authored Nov 15, 2023
1 parent 0311870 commit dae943e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions base/commands/migration/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
6 changes: 1 addition & 5 deletions base/commands/migration/migration_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions base/commands/migration/start_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dae943e

Please sign in to comment.