Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: add pod/container info in error form exec in pod. #2091

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func (c *Client) ExecInPod(ctx context.Context, namespace, pod, container string
}

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
7 changes: 4 additions & 3 deletions k8s/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ func (c *Client) execInPodWithWriters(connCtx, killCmdCtx context.Context, p Exe

func (c *Client) execInPod(ctx context.Context, p ExecParameters) (*ExecResult, error) {
result := &ExecResult{}
err := c.execInPodWithWriters(ctx, nil, p, &result.Stdout, &result.Stderr)

return result, err
if err := c.execInPodWithWriters(ctx, nil, p, &result.Stdout, &result.Stderr); err != nil {
return result, fmt.Errorf("error with exec request (pod=%s/%s, container=%s): %w", p.Namespace, p.Pod, p.Container, err)
}
return result, nil
}