diff --git a/k8s/client.go b/k8s/client.go index 25959d52b8..f11d7089ad 100644 --- a/k8s/client.go +++ b/k8s/client.go @@ -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 diff --git a/k8s/exec.go b/k8s/exec.go index 4482656eb7..cfbc961936 100644 --- a/k8s/exec.go +++ b/k8s/exec.go @@ -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 }