diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-12-20 17:28:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-20 17:28:40 +0100 |
commit | a830afdd99c0f20190f119d48eeab2ea751cdfb8 (patch) | |
tree | cd0b3fd0c901601f24189c32758b32333b926ae3 /client | |
parent | 66aae3a006e2778789f6f224cf4ecafa834c42cf (diff) | |
parent | 72240d0834661eca88265449bb67dd431c765342 (diff) |
Merge pull request #29721 from vespa-engine/mpolden/improve-msg
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 | 4 |
4 files changed, 17 insertions, 8 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..90d1e1997da 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. @@ -255,7 +255,7 @@ func wait(service *Service, okFn responseFunc, reqFn requestFunc, timeout, retry deadline := time.Now().Add(timeout) loopOnce := timeout == 0 for time.Now().Before(deadline) || loopOnce { - response, err = service.Do(reqFn(), 10*time.Second) + response, err = service.Do(reqFn(), 20*time.Second) if errors.Is(err, errAuth) { return status, fmt.Errorf("aborting wait: %w", err) } else if err == nil { |