Repository navigation
Use the client's kube context instead of the kubeconfig's current one - #3368
Open
pingxin403 wants to merge 1 commit into
Open
pingxin403 wants to merge 1 commit into
pingxin403 wants to merge 1 commit into
Conversation
IsMinikubeKubernetes indexed rawConfig.Contexts with the kubeconfig's own current context without checking that the entry exists, so a context selected with --kube-context panicked with a nil pointer when the kubeconfig pointed at a context it does not define. The lookup now uses the context the client was created with and checks both the context and its cluster. The kubectl manifest builder wrote the raw kubeconfig to a temporary file without updating its current context, so kubectl queried the cluster the kubeconfig selects rather than the one --kube-context names. The copied config now carries the client's context. Signed-off-by: pingxin403 <26605276+pingxin403@users.noreply.github.com>
✅ Deploy Preview for devspace-docs canceled.Built without sensitive environment variables
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3362
What
Both symptoms come from the kubeconfig's own
current-contextbeing used instead of the context the client was created with.IsMinikubeKubernetesreadrawConfig.Contexts[rawConfig.CurrentContext]and dereferenced the result without checking that the entry exists. With--kube-contextnaming a context the kubeconfig does not select, or a kubeconfig whosecurrent-contextis not defined, the lookup returns nil anddevspace buildpanics inIsMinikubeKubernetes(reported stack:util.go:256). The context is now the client'sCurrentContext(), and both the context and its cluster are checked before the cluster extensions are read.DeployConfig.buildManifestscopies the raw kubeconfig into a temporary file and hands it tokubectl createthroughKUBECONFIG, but never updatesCurrentContext, so kubectl queries whatever cluster the kubeconfig selects. The copy now setsCurrentContextto the client's context, so--kube-contextapplies to the kustomize/kubectl render as well.Tests
TestIsMinikubeContextcovers the four cases: a context the kubeconfig does not define (previously a nil dereference), a context whose cluster is missing, a cluster carrying the minikube provider extension, and a cluster without it.Negative check: removing the existence check reproduces
panic: runtime error: invalid memory address or nil pointer dereferencein the first case.go test ./pkg/devspace/kubectl/ ./pkg/devspace/deploy/deployer/kubectl/passes.