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

k8s: improve error messages during Pod exec failures #5557

Merged
merged 4 commits into from
Mar 4, 2022

Conversation

milas
Copy link
Contributor

@milas milas commented Mar 3, 2022

When running a command in a Pod, client-go attempts to handle
the failure case of a non-zero exit code by inspecting a
metav1.Status object.

For other failure cases, it returns fmt.Errorf(status.Message),
and Message might be blank, resulting in cryptic error messages
from Tilt.

There's not a lot we can do without upstream client-go changes
on the Tilt side, so some extra context is added around where the
exec failed, and for the stream error case, a generic fallback
error message is used if we get an empty error from client-go.

See remotecommand/v4.go for the problematic client-go code:
https://github.com/kubernetes/client-go/blob/8e46da3fd12b54a2d1726fc9a9438ff8fc38494c/tools/remotecommand/v4.go#L91-L118

When running a command in a Pod, `client-go` attempts to handle
the failure case of a non-zero exit code by inspecting a
`metav1.Status` object.

For other failure cases, it returns `fmt.Errorf(status.Message)`,
and `Message` might be blank, resulting in cryptic error messages
from Tilt.

There's not a lot we can do without upstream `client-go` changes
on the Tilt side, so some extra context is added around where the
exec failed, and for the stream error case, a generic fallback
error message is used if we get an empty error from `client-go`.
@milas milas requested review from nicksieger, nicks and landism March 3, 2022 14:44
@milas milas self-assigned this Mar 3, 2022
internal/k8s/exec.go Outdated Show resolved Hide resolved
@milas milas merged commit a3f17ca into master Mar 4, 2022
@milas milas deleted the milas/lu-error-msgs branch March 4, 2022 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants