Skip to content

Commit

Permalink
e2e: add pod/container info in error form exec in pod.
Browse files Browse the repository at this point in the history
When running connectivity tests, it's up to debug logs to provide information on failure errors.
This is not always the case, making it hard to understand where to start investigating errors.

This adds pod/container to the error message for calls to k8s exec to make it easier to understand where the issue occured.

Signed-off-by: Tom Hadlaw <[email protected]>
  • Loading branch information
tommyp1ckles committed Nov 6, 2023
1 parent dacac93 commit d1ad966
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,11 @@ func (c *Client) ExecInPod(ctx context.Context, namespace, pod, container string
Command: command,
})
if err != nil {
return bytes.Buffer{}, err
return bytes.Buffer{}, fmt.Errorf("error with exec request (pod=%s/%s, container=%s): %w", namespace, pod, container, err)
}

if errString := result.Stderr.String(); errString != "" {
return bytes.Buffer{}, fmt.Errorf("command failed: %s", errString)
return bytes.Buffer{}, fmt.Errorf("command failed (pod=%s/%s, container=%s): %q", namespace, pod, container, errString)
}

return result.Stdout, nil
Expand Down

0 comments on commit d1ad966

Please sign in to comment.