-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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: config migrate handles more valid configs #71315
Conversation
kubeadm config migrate uses AnyConfigFileAndDefaultsToInternal, which can unmarshal config from file only if InitConfiguration or JoinConfiguration are present. Even with that in mind, it can only return a singlie config object, with InitConfiguration taking precendence over JoinConfiguration. Thus, the following cases were not handled properly, while they were perfectly valid for kubeadm init/join: - ClusterConfiguration only file caused kubeadm config migrate to exit with error. - Init + Join configurations in the same file caused Init + Cluster configuration to be produced (ignoring JoinConfiguration). The same is valid when the combo is Init + Cluster + Join configurations. - Cluster + Join configuration ignores ClusterConfiguration and only JoinConfiguration gets migrated. To fix this, the following is done: - Introduce MigrateOldConfigFromFile which migrates old config from a file, while ensuring that all kubeadm originated input config kinds are taken care of. Add comprehensive unit tests for this. - Replace the use of AnyConfigFileAndDefaultsToInternal in kubeadm config migrate with MigrateOldConfigFromFile. - Remove the no longer used and error prone AnyConfigFileAndDefaultsToInternal. Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
|
||
// Migrate InitConfiguration and ClusterConfiguration if there are any in the config | ||
if kubeadmutil.GroupVersionKindsHasInitConfiguration(gvks...) || kubeadmutil.GroupVersionKindsHasClusterConfiguration(gvks...) { | ||
o, err := ConfigFileAndDefaultsToInternalConfig(cfgPath, &kubeadmapiv1beta1.InitConfiguration{}) |
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.
I think we can do some refactoring for ConfigFileAndDefaultsToInternalConfig
, since the file will be read twice. There is no need.
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.
Yes, that's on my agenda for the next release cycle. Decoupling InitConfiguration and ClusterConfiguration is one of my priorities. If we refactor the APIs and make ClusterConfiguration more standalone and introduce an internal type that houses the usual pair (ClusterConfiguration + NodeRegistrationOptions for the current node) we can eliminate most of the confusion and optimize things at all levels.
But for now at the end of this release cycle it's best to keep the changes as small as possible and just fix the bug at hand.
|
||
// Migrate JoinConfiguration if there is any | ||
if kubeadmutil.GroupVersionKindsHasJoinConfiguration(gvks...) { | ||
o, err := JoinConfigFileAndDefaultsToInternalConfig(cfgPath, &kubeadmapiv1beta1.JoinConfiguration{}) |
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.
same as above.
/test pull-kubernetes-integration |
/priority critical-urgent |
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 @rosti
LGTM
/retest |
1 similar comment
/retest |
/milestone v1.13 |
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.
@rosti thanks for this quick fix!
/approve
@luxas @timothysc could you kindly take a look / give final lgtm?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabriziopandini, rosti 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 |
/retest |
/test pull-kubernetes-integration |
/lgtm further comments? unhold by EOD tomorrow. |
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
Thanks for the bugfix!
What type of PR is this?
/kind bug
What this PR does / why we need it:
kubeadm config migrate uses AnyConfigFileAndDefaultsToInternal, which can
unmarshal config from file only if InitConfiguration or JoinConfiguration are
present. Even with that in mind, it can only return a singlie config object,
with InitConfiguration taking precendence over JoinConfiguration. Thus, the
following cases were not handled properly, while they were perfectly valid for
kubeadm init/join:
error.
configuration to be produced (ignoring JoinConfiguration). The same is valid
when the combo is Init + Cluster + Join configurations.
JoinConfiguration gets migrated.
To fix this, the following is done:
while ensuring that all kubeadm originated input config kinds are taken care
of. Add comprehensive unit tests for this.
kubeadm config migrate with MigrateOldConfigFromFile.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes kubernetes/kubeadm#1262
Special notes for your reviewer:
/cc @kubernetes/sig-cluster-lifecycle-pr-reviews
/area kubeadm
/assign @fabriziopandini
/assign @timothysc
/assign @luxas
Does this PR introduce a user-facing change?: