From ed1b1b54cdf06ecaeec4f3a53294db0b146edbec Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Tue, 31 Oct 2017 09:19:20 +0100 Subject: [PATCH] docker: render errors with %v since they can be nil --- agent/checks/docker.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/agent/checks/docker.go b/agent/checks/docker.go index 3644a6852..78ce10192 100644 --- a/agent/checks/docker.go +++ b/agent/checks/docker.go @@ -141,7 +141,7 @@ func (c *DockerClient) CreateExec(containerID string, cmd []string) (string, err b, code, err := c.call("POST", uri, data) switch { case err != nil: - return "", fmt.Errorf("create exec failed for container %s: %s", containerID, err) + return "", fmt.Errorf("create exec failed for container %s: %v", containerID, err) case code == 201: var resp struct{ Id string } if err = json.NewDecoder(bytes.NewReader(b.Bytes())).Decode(&resp); err != nil { @@ -169,7 +169,7 @@ func (c *DockerClient) StartExec(containerID, execID string) (*circbuf.Buffer, e // todo(fs): that the docker agent closes this prematurely but I don't understand why. // todo(fs): the code below ignores this error. case err != nil && !strings.Contains(err.Error(), "connection reset by peer"): - return nil, fmt.Errorf("start exec failed for container %s: %s", containerID, err) + return nil, fmt.Errorf("start exec failed for container %s: %v", containerID, err) case code == 200: return b, nil case code == 404: @@ -177,7 +177,7 @@ func (c *DockerClient) StartExec(containerID, execID string) (*circbuf.Buffer, e case code == 409: return nil, fmt.Errorf("start exec failed since container %s is paused or stopped", containerID) default: - return nil, fmt.Errorf("start exec failed for container %s with status %d: body: %s err: %s", containerID, code, b, err) + return nil, fmt.Errorf("start exec failed for container %s with status %d: body: %s err: %v", containerID, code, b, err) } } @@ -190,7 +190,7 @@ func (c *DockerClient) InspectExec(containerID, execID string) (int, error) { case code == 200: var resp struct{ ExitCode int } if err := json.NewDecoder(bytes.NewReader(b.Bytes())).Decode(&resp); err != nil { - return 0, fmt.Errorf("inspect exec response for container %s cannot be parsed: %s", containerID, err) + return 0, fmt.Errorf("inspect exec response for container %s cannot be parsed: %v", containerID, err) } return resp.ExitCode, nil case code == 404: