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

Fix panic when kubeconfig is not valid #26

Merged
merged 2 commits into from
Jul 30, 2021

Conversation

TyBrown
Copy link
Contributor

@TyBrown TyBrown commented Jul 29, 2021

If the kubeconfig is invalid for some reason (misconfigured, typo, etc.), currently kbenv will panic with a stacktrace that doesn't really say what's gone wrong. At the very least, we can handle the underlying error and exit to avoid the stacktrace.

Before:

$ kubectl get pod
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x1e0 pc=0x1c89b0f]

goroutine 1 [running]:
github.com/little-angry-clouds/kubernetes-binaries-managers/internal/helpers.KubeGetVersion(0xc0000b762c, 0x4, 0x1ef5168, 0x1)
	/private/tmp/kbenv-20210729-90323-1ezpqxa/kubernetes-binaries-managers-0.2.6/internal/helpers/kube_client.go:57 +0x10f
github.com/little-angry-clouds/kubernetes-binaries-managers/internal/wrapper.Wrapper(0x1e64889, 0x7)
	/private/tmp/kbenv-20210729-90323-1ezpqxa/kubernetes-binaries-managers-0.2.6/internal/wrapper/main.go:61 +0x77f
main.main()
	/private/tmp/kbenv-20210729-90323-1ezpqxa/kubernetes-binaries-managers-0.2.6/cmd/kubectl-wrapper/main.go:10 +0x36

After:

$ ./kubectl-wrapper get pod
kbenv failed to load kubeconfig: invalid configuration: no configuration has been provided

@alexppg
Copy link
Member

alexppg commented Jul 30, 2021

Thanks for the contribution and the error report! I've created an issue, which you can see above, in case you'd like to add a test for this. I'll merge it right away anyway.

@alexppg alexppg merged commit 1cd24e2 into little-angry-clouds:master Jul 30, 2021
@alexppg
Copy link
Member

alexppg commented Jul 31, 2021

There's a release with this changes. Thanks again!

@TyBrown
Copy link
Contributor Author

TyBrown commented Jul 31, 2021

Thanks for letting me know about the release! I'll be sure to update when I get back to work on Monday! :) I appreciate your quick response to merging this in and getting it out! :)

@TyBrown TyBrown deleted the tbrown/fix_panic branch October 20, 2021 18:45
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.

2 participants