-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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: Extended KubeletVersionCheck #54868
Conversation
/test pull-kubernetes-bazel-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.
Thanks for this PR, great!
I left some comments
cmd/kubeadm/app/preflight/checks.go
Outdated
if err != nil { | ||
return nil, []error{fmt.Errorf("couldn't parse kubernetes version %q: %v", kubever.KubernetesVersion, err)} | ||
} | ||
firstUnsupportedKubeletVersion := versionutil.MustParseSemantic(fmt.Sprintf("%d.%d.%s", k8sVersion.Major(), k8sVersion.Minor()+1, "0-0")) |
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.
This can be simpler I think... Why not just do if kubeletVersion.Minor() > k8sVersion.Minor()
=> error?
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.
While developing next minor version, it is fine to have kubelet a bit newer than control plane.
e.g. testing kubelet 1.9.0-alpha.3+gitXYZ on top of 1.8.x stable cluster. Just be a bit more handy for developers.
Release 1.9.0 will complain, but development builds before 1.9.0 release will be ok.
cmd/kubeadm/app/preflight/checks.go
Outdated
} | ||
firstUnsupportedKubeletVersion := versionutil.MustParseSemantic(fmt.Sprintf("%d.%d.%s", k8sVersion.Major(), k8sVersion.Minor()+1, "0-0")) | ||
if kubeletVersion.AtLeast(firstUnsupportedKubeletVersion) { | ||
return []error{fmt.Errorf("kubernetes version is lower than kubelet version. This may lead to malfunctional cluster setup. Kubernetes version: %s. Kubelet version: %s", k8sVersion, kubeletVersion)}, 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.
suggest: The kubelet version is higher than the control plane version. This is not a supported version skew and may lead to a malfunctional cluster. Kubelet version: %s. Control plane version: %s.
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.
Also I think this should be an error
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'd suggest to keep it as warning. We don't break every single release interfaces between kubelet and control plane. It might be some cases where it will work incorrectly, but generally it should work. But I can change that to error, not big deal, as soon we will have custom controls on pre-flight checks :)
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.
As it never is guaranteed to be a supported state, I want it to be an error. Please fix as above
} | ||
|
||
cases := []T{ | ||
{"v1.7.3", "v1.7.8", true, false}, // Too old kubelet |
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.
this confused me first: please say // too old kubelet generally, v1.7 kubelets not supported anymore
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.
That is intentional, to check error path with kubeadmconstants.MinimumKubeletVersion
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.
yeah, but I'd appreciate if you changed the comment to be clearer. That was my intention
{"v1.7.3", "v1.7.8", true, false}, // Too old kubelet | ||
{"v1.9.0", "v1.9.5", false, false}, // kubelet within same major.minor as control plane | ||
{"v1.9.0", "v1.10.1", false, false}, // kubelet is lower than control plane, but newer than minimally supported | ||
{"v1.10.0-alpha.1", "v1.9.1", false, true}, // kubelet is newer than control plane |
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 would expect this to fail
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.
Also add a proper v1.10.3
and v1.9.4
test that should fail
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.
Using development builds of kubelet on top of stable control plane would be good to allow. See other comment.
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.
ok
defer os.RemoveAll(dir) | ||
|
||
// We don't want to call real kubelet or something else in $PATH | ||
oldPATH := os.Getenv("PATH") |
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.
Can you please re-engineer this to use k8s.io/utils/exec
for this instead so you can fake out the exec calls in unit tests instead of doing this?
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 haven't noticed that lib. Will check it. From quick look, it might require change also in implementation of GetKubeletVersion()
. Do you want to have it as part of this PR or maybe let's do re-factoring to use utils/exec as separate PR ?
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.
Follow up is fine by me
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.
After the last comments are addressed, I'll LGTM
} | ||
|
||
cases := []T{ | ||
{"v1.7.3", "v1.7.8", true, false}, // Too old kubelet |
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.
yeah, but I'd appreciate if you changed the comment to be clearer. That was my intention
cmd/kubeadm/app/preflight/checks.go
Outdated
} | ||
firstUnsupportedKubeletVersion := versionutil.MustParseSemantic(fmt.Sprintf("%d.%d.%s", k8sVersion.Major(), k8sVersion.Minor()+1, "0-0")) | ||
if kubeletVersion.AtLeast(firstUnsupportedKubeletVersion) { | ||
return []error{fmt.Errorf("kubernetes version is lower than kubelet version. This may lead to malfunctional cluster setup. Kubernetes version: %s. Kubelet version: %s", k8sVersion, kubeletVersion)}, 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.
As it never is guaranteed to be a supported state, I want it to be an error. Please fix as above
{"v1.7.3", "v1.7.8", true, false}, // Too old kubelet | ||
{"v1.9.0", "v1.9.5", false, false}, // kubelet within same major.minor as control plane | ||
{"v1.9.0", "v1.10.1", false, false}, // kubelet is lower than control plane, but newer than minimally supported | ||
{"v1.10.0-alpha.1", "v1.9.1", false, true}, // kubelet is newer than control plane |
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.
ok
defer os.RemoveAll(dir) | ||
|
||
// We don't want to call real kubelet or something else in $PATH | ||
oldPATH := os.Getenv("PATH") |
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.
Follow up is fine by me
5dfa888
to
18f486c
Compare
updated with making it as an error and addressing other comments. |
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 @kad!
KubeletVersionCheck now able to detect if kubelet version is higher than control plane. As this might lead to malfunctional cluster setups, kubeadm will give warning. Fixes: kubernetes/kubeadm#496
18f486c
to
de272d0
Compare
Sorry @luxas needed to push once again with fix for golint issue :( |
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
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kad, luxas Associated issue: 496 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. |
What this PR does / why we need it:
KubeletVersionCheck now able to detect if kubelet version
is higher than control plane. As this might lead to malfunctional
cluster setups, kubeadm will give warning.
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#496
Special notes for your reviewer:
/sig cluster-lifecycle
/area kubeadm
Release note: