diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-12-20 15:05:05 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-12-20 15:08:37 +0100 |
commit | 29225f7f44b596c0220dcecc90fa3289d73064b6 (patch) | |
tree | c3402efbd2cbc320fa43cacd34c47400e9acff0c /client | |
parent | 4e36216e36a0e57fe8da52840e4e940927edeb2c (diff) |
Print less severe message for incomplete deployment
Diffstat (limited to 'client')
-rw-r--r-- | client/go/internal/cli/cmd/root.go | 7 | ||||
-rw-r--r-- | client/go/internal/cli/cmd/status.go | 6 | ||||
-rw-r--r-- | client/go/internal/cli/cmd/status_test.go | 8 | ||||
-rw-r--r-- | client/go/internal/vespa/target.go | 2 |
4 files changed, 16 insertions, 7 deletions
diff --git a/client/go/internal/cli/cmd/root.go b/client/go/internal/cli/cmd/root.go index 383ce7dd28d..8e0f3de4f72 100644 --- a/client/go/internal/cli/cmd/root.go +++ b/client/go/internal/cli/cmd/root.go @@ -69,6 +69,7 @@ type CLI struct { // the error. type ErrCLI struct { Status int + warn bool quiet bool hints []string error @@ -599,7 +600,11 @@ func (c *CLI) Run(args ...string) error { if err != nil { if cliErr, ok := err.(ErrCLI); ok { if !cliErr.quiet { - c.printErr(cliErr, cliErr.hints...) + if cliErr.warn { + c.printWarning(cliErr, cliErr.hints...) + } else { + c.printErr(cliErr, cliErr.hints...) + } } } else { c.printErr(err) diff --git a/client/go/internal/cli/cmd/status.go b/client/go/internal/cli/cmd/status.go index 29a4a5775db..6056ee439b2 100644 --- a/client/go/internal/cli/cmd/status.go +++ b/client/go/internal/cli/cmd/status.go @@ -176,7 +176,11 @@ $ vespa status deployment -t local [session-id] --wait 600 waiter := cli.waiter(time.Duration(waitSecs) * time.Second) id, err := waiter.Deployment(t, wantedID) if err != nil { - return err + var hints []string + if waiter.Timeout == 0 { + hints = []string{"Consider using the --wait flag to wait for completion"} + } + return ErrCLI{Status: 1, warn: true, hints: hints, error: err} } if t.IsCloud() { log.Printf("Deployment run %s has completed", color.CyanString(strconv.FormatInt(id, 10))) diff --git a/client/go/internal/cli/cmd/status_test.go b/client/go/internal/cli/cmd/status_test.go index 3c6277b9050..5ef96c462d8 100644 --- a/client/go/internal/cli/cmd/status_test.go +++ b/client/go/internal/cli/cmd/status_test.go @@ -85,7 +85,7 @@ func TestStatusError(t *testing.T) { cli.httpClient = client assert.NotNil(t, cli.Run("status", "container")) assert.Equal(t, - "Container default at http://127.0.0.1:8080 is not ready: unhealthy container default: status 500 at http://127.0.0.1:8080/status.html: wait timed out\n", + "Container default at http://127.0.0.1:8080 is not ready: unhealthy container default: status 500 at http://127.0.0.1:8080/status.html: giving up\n", stdout.String()) assert.Equal(t, "Error: services not ready: default\n", @@ -122,13 +122,13 @@ func TestStatusLocalDeployment(t *testing.T) { resp.Body = []byte(`{"currentGeneration": 42, "converged": false}`) client.NextResponse(resp) assert.NotNil(t, cli.Run("status", "deployment")) - assert.Equal(t, "Error: deployment not converged on latest generation: wait timed out\n", stderr.String()) + assert.Equal(t, "Warning: deployment not converged on latest generation: giving up\nHint: Consider using the --wait flag to wait for completion\n", stderr.String()) // Explicit generation stderr.Reset() client.NextResponse(resp) assert.NotNil(t, cli.Run("status", "deployment", "41")) - assert.Equal(t, "Error: deployment not converged on generation 41: wait timed out\n", stderr.String()) + assert.Equal(t, "Warning: deployment not converged on generation 41: giving up\nHint: Consider using the --wait flag to wait for completion\n", stderr.String()) } func TestStatusCloudDeployment(t *testing.T) { @@ -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...\nError: 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: 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 543ce2f4a29..36f69583b9a 100644 --- a/client/go/internal/vespa/target.go +++ b/client/go/internal/vespa/target.go @@ -36,7 +36,7 @@ const ( AnyDeployment int64 = -2 ) -var errWaitTimeout = errors.New("wait timed out") +var errWaitTimeout = errors.New("giving up") var errAuth = errors.New("auth failed") // Authenticator authenticates the given HTTP request. |