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-282]: Fix timeout message #435

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