-
Notifications
You must be signed in to change notification settings - Fork 38.9k
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
Allow to use version labels in kubeadm upgrade apply command. #53043
Conversation
Hi @kad. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
There is one missing functionality in that PR: if user tries to use kubeadm upgrade apply to the latest CI version, it is possible that kubeadm will complain that it is older than version we want to upgrade to. It is probably will be good to implement as separate PR. |
/ok-to-test |
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.
mostly nits, LGTM generally
cmd/kubeadm/app/cmd/upgrade/apply.go
Outdated
@@ -123,6 +123,19 @@ func RunApply(flags *applyFlags) error { | |||
internalcfg := &kubeadmapi.MasterConfiguration{} | |||
api.Scheme.Convert(upgradeVars.cfg, internalcfg, nil) | |||
|
|||
// Validate requested and validate actual version | |||
if err := configutil.NormalizeKubernetsVersion(internalcfg); err != 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.
NormalizeKubernetesVersion
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.
heh. typo :(
BTW, maybe make it as interface to MasterConfiguration ? so it will be
if err := internalcfg.NormalizeKubernetesVersion(); err != nil {
...
instead of configutil.NormalizeKubernetesVersion(internalcfg)
?
This function is anyway usable only with that type.
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.
haven't decided how to generally deal with that, so as-is is fine for now
@@ -92,6 +97,18 @@ func KubernetesIsCIVersion(version string) bool { | |||
return false | |||
} | |||
|
|||
// Internal helper: returns normalized build version (with "v" prefix if needed) | |||
// If input doesn't match known version pattern, returns empty string. | |||
func normalizedBuildVersion(version string) string { |
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 have unit test
cfg.CIImageRepository = kubeadmconstants.DefaultCIImageRepository | ||
} | ||
|
||
// Validate version argument |
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.
Parse the version argument and resolve possible CI version labels
cmd/kubeadm/app/cmd/upgrade/apply.go
Outdated
if !strings.HasPrefix(flags.newK8sVersionStr, "v") { | ||
flags.newK8sVersionStr = fmt.Sprintf("v%s", flags.newK8sVersionStr) | ||
if len(flags.newK8sVersionStr) == 0 { | ||
return fmt.Errorf("Version string can't be empty") |
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.
error msgs should start with lowercase
cmd/kubeadm/app/cmd/upgrade/apply.go
Outdated
flags.newK8sVersionStr = internalcfg.KubernetesVersion | ||
k8sVer, err := version.ParseSemantic(flags.newK8sVersionStr) | ||
if err != nil { | ||
return fmt.Errorf("Unable parse normalized version %q as a semantic version", flags.newK8sVersionStr) |
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.
unable
thx, will update. |
kubeadm upgrade apply now is able to utilize all possible combinations of version argument, including labels (latest, stable-1.8, ci/latest-1.9) as well as specific builds (v1.8.0-rc.1, ci/v1.9.0-alpha.1.123_01234567889) As side effect, specifying exact build to deploy from CI area is now also possible in kubeadm init command. Fixes: kubernetes/kubeadm#451
ok, unit test added, all other typos should to be fixed now. |
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
Thanks 🎉!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kad, luxas Associated issue: 451 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
@kad: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
What this PR does / why we need it:
kubeadm upgrade apply now is able to utilize all possible combinations
of version argument, including labels (latest, stable-1.8, ci/latest-1.9)
as well as specific builds (v1.8.0-rc.1, ci/v1.9.0-alpha.1.123_01234567889)
As side effect, specifying exact build to deploy from CI area is now also
possible in kubeadm init command.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes kubernetes/kubeadm#451Special notes for your reviewer:
cc @luxas
Release note: