diff --git a/k8s/client.go b/k8s/client.go index d42f6a0a11..27d2a3be63 100644 --- a/k8s/client.go +++ b/k8s/client.go @@ -437,7 +437,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..7bbb37d867 100644 --- a/k8s/exec.go +++ b/k8s/exec.go @@ -74,6 +74,5 @@ 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 + return result, fmt.Errorf("error with exec request (pod=%s/%s, container=%s): %w", p.Namespace, p.Pod, p.Container, err) }