diff options
author | Martin Polden <mpolden@mpolden.no> | 2024-06-05 15:34:27 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2024-06-05 15:34:27 +0200 |
commit | b8f472d0e7d4e9349db02fbbb5294174a0f520a3 (patch) | |
tree | e0f225c761588fcbc51f9ea227ad5d045b244fe5 /client/go/internal | |
parent | fade25bcac73e460b4bbded53f1821e7edb7e626 (diff) |
Only suggest --wait for non-terminal errors
Diffstat (limited to 'client/go/internal')
-rw-r--r-- | client/go/internal/cli/cmd/status.go | 3 | ||||
-rw-r--r-- | client/go/internal/cli/cmd/status_test.go | 2 | ||||
-rw-r--r-- | client/go/internal/vespa/target.go | 3 | ||||
-rw-r--r-- | client/go/internal/vespa/target_cloud.go | 2 |
4 files changed, 7 insertions, 3 deletions
diff --git a/client/go/internal/cli/cmd/status.go b/client/go/internal/cli/cmd/status.go index 6056ee439b2..e1c329ba993 100644 --- a/client/go/internal/cli/cmd/status.go +++ b/client/go/internal/cli/cmd/status.go @@ -5,6 +5,7 @@ package cmd import ( + "errors" "fmt" "log" "strconv" @@ -177,7 +178,7 @@ $ vespa status deployment -t local [session-id] --wait 600 id, err := waiter.Deployment(t, wantedID) if err != nil { var hints []string - if waiter.Timeout == 0 { + if waiter.Timeout == 0 && !errors.Is(err, vespa.ErrDeployment) { hints = []string{"Consider using the --wait flag to wait for completion"} } return ErrCLI{Status: 1, warn: true, hints: hints, error: err} diff --git a/client/go/internal/cli/cmd/status_test.go b/client/go/internal/cli/cmd/status_test.go index 5ef96c462d8..80afd79e296 100644 --- a/client/go/internal/cli/cmd/status_test.go +++ b/client/go/internal/cli/cmd/status_test.go @@ -164,7 +164,7 @@ func TestStatusCloudDeployment(t *testing.T) { Body: []byte(`{"active": false, "status": "failure"}`), }) assert.NotNil(t, cli.Run("status", "deployment", "42", "-w", "10")) - assert.Equal(t, "Waiting up to 10s for deployment to converge...\nWarning: deployment run 42 incomplete after waiting up to 10s: aborting wait: run 42 ended with unsuccessful status: failure\n", stderr.String()) + assert.Equal(t, "Waiting up to 10s for deployment to converge...\nWarning: deployment run 42 incomplete after waiting up to 10s: aborting wait: deployment failed: run 42 ended with unsuccessful status: failure\n", stderr.String()) } func isLocalTarget(args []string) bool { diff --git a/client/go/internal/vespa/target.go b/client/go/internal/vespa/target.go index 94eb2cbafe4..c1a7747f978 100644 --- a/client/go/internal/vespa/target.go +++ b/client/go/internal/vespa/target.go @@ -39,6 +39,9 @@ const ( var errWaitTimeout = errors.New("giving up") var errAuth = errors.New("auth failed") +// ErrDeployment is the error returned for terminal deployment failures. +var ErrDeployment = errors.New("deployment failed") + // Authenticator authenticates the given HTTP request. type Authenticator interface { Authenticate(request *http.Request) error diff --git a/client/go/internal/vespa/target_cloud.go b/client/go/internal/vespa/target_cloud.go index c063b99edef..da57fc66807 100644 --- a/client/go/internal/vespa/target_cloud.go +++ b/client/go/internal/vespa/target_cloud.go @@ -309,7 +309,7 @@ func (t *cloudTarget) AwaitDeployment(runID int64, timeout time.Duration) (int64 return false, nil } if resp.Status != "success" { - return false, fmt.Errorf("run %d ended with unsuccessful status: %s", runID, resp.Status) + return false, fmt.Errorf("%w: run %d ended with unsuccessful status: %s", ErrDeployment, runID, resp.Status) } success = true return success, nil |