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: handle stable-1 as the default version #69301

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

neolit123
Copy link
Member

@neolit123 neolit123 commented Oct 1, 2018

What this PR does / why we need it:
The default version in kubeadm is now stable-1. This will
pull a version from the stable-1.txt endpoint which might
end up being newer than the version of the client by a magnitude
of MINOR or even a MAJOR release.

To be able to prevent this scenario add the new helper function:
validateStableVersion()

This function determines if the remote version is newer than the
local client version and if that's the case it returns stable-X.xx
that conforms with the version of the client. If not it returns
the remote version.

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#1141

Special notes for your reviewer:

  • the unit tests can illustrate what the function does.
  • NOTE: we need to backport this to 1.12 !!!

Release note:

kubeadm: fix a possible scenario where kubeadm can pull much newer control-plane images

/kind bug
/assign @kad @timothysc
@kubernetes/sig-cluster-lifecycle-pr-reviews

@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Oct 1, 2018
@k8s-ci-robot k8s-ci-robot added sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 1, 2018
@neolit123
Copy link
Member Author

looks like the remote CI tests don't populate a client version properly when building the kubeadm binary....
"v0.0.0-master+$Format:%h$"

this would require a workaround.

@neolit123
Copy link
Member Author

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 1, 2018
if _, err := versionutil.ParseSemantic(pkgversion.Get().String()); err == nil {
// ignore the error as kubeadmVersion() cannot fail at this point
clientVersion, _ = kubeadmVersion(pkgversion.Get().String())
}
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'm not very happy with how this is turning out.
will revise tomorrow. the idea is to always get some sort of a client version: A) a valid one, B) empty string.

might as well remove the error check from kubeadmVersion() and adjust related sub-unit-tests.

@neolit123 neolit123 changed the title kubeadm: handle stable-1 as the default version [WIP]: kubeadm: handle stable-1 as the default version Oct 1, 2018
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 1, 2018
@neolit123 neolit123 changed the title [WIP]: kubeadm: handle stable-1 as the default version kubeadm: handle stable-1 as the default version Oct 4, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 4, 2018
// This is done to conform with "stable-X" and only allow remote versions from
// the same Patch level release.
func validateStableVersion(remoteVersion, clientVersion string) (string, error) {
const errorFormat = "validateStableVersion(): %s version error: %v"
Copy link
Member

Choose a reason for hiding this comment

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

Should really just use errors.wrap below, this is kind of weird.

Copy link
Member Author

Choose a reason for hiding this comment

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

ack.

if verClient.Major() < verRemote.Major() ||
(verClient.Major() == verRemote.Major()) && verClient.Minor() < verRemote.Minor() {
estimatedRelease := fmt.Sprintf("stable-%d.%d", verClient.Major(), verClient.Minor())
glog.Infof("remote version is much newer: %s; falling back to: %s", remoteVersion, estimatedRelease)
Copy link
Member

Choose a reason for hiding this comment

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

This almost seems like a bug.
If a person has 1.11.1 download, they should be able to get the latest 1.11.y and it should just work, if we fallback that's almost unexpected behavior.

imo we need to switch back to stable-1.X in the 1.12 series bits.

Copy link
Member Author

@neolit123 neolit123 Oct 4, 2018

Choose a reason for hiding this comment

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

If a person has 1.11.1 download, they should be able to get the latest 1.11.y

the above code should do just that.

for 1.11.1 it falls back to stable-1.11, which can be e.g. 1.11.5.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh I see that now. K, I'm good.

Copy link
Member

@timothysc timothysc left a comment

Choose a reason for hiding this comment

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

/approve

just fix up the error handling then lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: neolit123, timothysc

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 4, 2018
The default version in kubeadm is now `stable-1`. This will
pull a version from the `stable-1.txt` endpoint which might
end up being newer than the version of the client by a magnitude
of MINOR or even a MAJOR release.

To be able to prevent this scenario add the new helper function:
validateStableVersion()

This function determines if the remote version is newer than the
local client version and if that's the case it returns `stable-X.xx`
that conforms with the version of the client. If not it returns
the remote version.
@neolit123
Copy link
Member Author

updated.
errors simplified to: fmt.Errorf("client version error: %v", err)

@neolit123
Copy link
Member Author

we possibly want this for .2 at least if not for .1.

Copy link
Member

@timothysc timothysc left a comment

Choose a reason for hiding this comment

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

/lgtm

please use error.Wrap in subsequent PRs.


verRemote, err := versionutil.ParseGeneric(remoteVersion)
if err != nil {
return "", fmt.Errorf("remote version error: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

grumble ... errors.Wrap

Copy link
Member Author

Choose a reason for hiding this comment

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

sure.
i don't like that it's not part of golang yet, but we can possibly SED them all at once.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 10, 2018
@neolit123
Copy link
Member Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 10, 2018
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 10, 2018
// the same Patch level release.
func validateStableVersion(remoteVersion, clientVersion string) (string, error) {
if clientVersion == "" {
glog.Infof("could not obtain client version; using remote version: %s", remoteVersion)
Copy link
Member

Choose a reason for hiding this comment

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

glog should be used with verbosity level, isn't it ?

Copy link
Member Author

Choose a reason for hiding this comment

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

unless we want to always show the warning with file and line, etc, no?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see that as a critical warning, but ok.

return remoteVersion, nil
}

verRemote, err := versionutil.ParseGeneric(remoteVersion)
Copy link
Member

Choose a reason for hiding this comment

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

In theory, here we have content of remote file. right now, it is supposed to be exact version. but the idea of recursive validation was that if label 'stable-1' will be resolved to another label, e.g. 'stable-1.12', this function will try to resolve one more remote label. If this function will expect that remote content is always parsable version, it will break previous functionality.

Copy link
Member Author

@neolit123 neolit123 Oct 10, 2018

Choose a reason for hiding this comment

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

thanks for the review but this was in flight for 10 days.
also just created the cherry pick for 1.12.

i see what you are saying but in my tests i wasn't able to reach such a breakage.
we do fall-back to stable-1.12, if stable-1 is much newer, recurse and it works fine.

now, if stable-1 returns a non-semantic version as contents, that's really a breakage with the endpoint from my perspective.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for delay with commenting on that, somehow screwed up notifications on this PR :(

Yes, that scenario is not covered by tests. It was previously implicitly working with nesting of the labels. Support for nested label resolution is not critical, but nice to have. I can do separate PR for that later on.

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds good! thanks.

@neolit123
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit 77742ea into kubernetes:master Oct 10, 2018
k8s-ci-robot added a commit that referenced this pull request Oct 11, 2018
…301-origin-release-1.12

Automated cherry pick of #69301: kubeadm: handle stable-1 as the default version
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. kind/bug Categorizes issue or PR as related to a bug. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

handle version skew scenarios due to stable-1
4 participants