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
kubeadm: improve the kubeconfig file validation phase #79165
kubeadm: improve the kubeconfig file validation phase #79165
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: neolit123 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @neolit123
@@ -224,7 +224,13 @@ func validateKubeConfig(outDir, filename string, config *clientcmdapi.Config) er | |||
expectedCtx := config.CurrentContext | |||
expectedCluster := config.Contexts[expectedCtx].Cluster | |||
currentCtx := currentConfig.CurrentContext | |||
if config.Contexts[currentCtx] == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be currentConfig
? Also, should we check the config.Contexts[expectedCtx].Cluster
above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be currentConfig?
yeah already sent a change.
Also, should we check the config.Contexts[expectedCtx].Cluster above
its a file we just generated, so doesn't seem we need to.
When a kubeconfig file is read from disk it may lack the propper mapping between contexts and clusters. In such a case the kubeconfig phase backend will panic, without throwing a sensible error. Add nil checks for a couple of map operations in validateKubeConfig().
12866fc
to
14408be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @neolit123 !
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/hold cancel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neolit123 many thanks for this fix!
/approve
/lgtm
Are U planning to back port this fix in older releases?
What this PR does / why we need it:
When a kubeconfig file is read from disk it may lack the
propper mapping between contexts and clusters.
In such a case the kubeconfig phase backend will panic,
without throwing a sensible error.
Add nil checks for a couple of map operations in
validateKubeConfig().
Which issue(s) this PR fixes:
Fixes #79069
xref kubernetes/kubeadm#1382
Special notes for your reviewer:
NONE
Does this PR introduce a user-facing change?:
/priority backlog
/assign @fabriziopandini @rosti
/kind bug
@kubernetes/sig-cluster-lifecycle-pr-reviews
/hold