Skip to content
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

Merged
merged 1 commit into from
Nov 9, 2017

Conversation

kad
Copy link
Member

@kad kad commented Oct 31, 2017

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:

- kubeadm will produce error if kubelet too new for control plane

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. area/kubeadm size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 31, 2017
@kad
Copy link
Member Author

kad commented Oct 31, 2017

/test pull-kubernetes-bazel-test

@kad
Copy link
Member Author

kad commented Nov 3, 2017

@krousey @dmmcquay any opinion on PR ?

Copy link
Member

@luxas luxas left a 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

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"))
Copy link
Member

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?

Copy link
Member Author

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.

}
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
Copy link
Member

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.

Copy link
Member

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

Copy link
Member Author

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 :)

Copy link
Member

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
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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
Copy link
Member

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

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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")
Copy link
Member

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?

Copy link
Member Author

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 ?

Copy link
Member

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

Copy link
Member

@luxas luxas left a 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
Copy link
Member

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

}
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
Copy link
Member

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
Copy link
Member

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")
Copy link
Member

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

@kad
Copy link
Member Author

kad commented Nov 8, 2017

updated with making it as an error and addressing other comments.

Copy link
Member

@luxas luxas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Thanks @kad!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2017
@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 8, 2017
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
@kad
Copy link
Member Author

kad commented Nov 8, 2017

Sorry @luxas needed to push once again with fix for golint issue :(

Copy link
Member

@luxas luxas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2017
@kad
Copy link
Member Author

kad commented Nov 9, 2017

/retest

@luxas
Copy link
Member

luxas commented Nov 9, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 9, 2017
@k8s-github-robot
Copy link

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 065e450 into kubernetes:master Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubeadm init specifying a version may result in a kubelet version mismatch
6 participants