-
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: handle stable-1 as the default version #69301
kubeadm: handle stable-1 as the default version #69301
Conversation
looks like the remote CI tests don't populate a client version properly when building the kubeadm binary.... this would require a workaround. |
ea1ec80
to
70bceaa
Compare
/hold |
cmd/kubeadm/app/util/version.go
Outdated
if _, err := versionutil.ParseSemantic(pkgversion.Get().String()); err == nil { | ||
// ignore the error as kubeadmVersion() cannot fail at this point | ||
clientVersion, _ = kubeadmVersion(pkgversion.Get().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.
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.
70bceaa
to
911ac67
Compare
cmd/kubeadm/app/util/version.go
Outdated
// 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" |
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 really just use errors.wrap below, this is kind of weird.
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.
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) |
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 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.
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.
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.
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.
Ahh I see that now. K, I'm good.
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.
/approve
just fix up the error handling then lgtm
[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 |
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.
911ac67
to
5054135
Compare
updated. |
we possibly want this for |
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
please use error.Wrap in subsequent PRs.
|
||
verRemote, err := versionutil.ParseGeneric(remoteVersion) | ||
if err != nil { | ||
return "", fmt.Errorf("remote version error: %v", err) |
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.
grumble ... errors.Wrap
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.
sure.
i don't like that it's not part of golang yet, but we can possibly SED them all at once.
/hold cancel |
// 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) |
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.
glog should be used with verbosity level, isn't it ?
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.
unless we want to always show the warning with file and line, etc, no?
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 don't see that as a critical warning, but ok.
return remoteVersion, nil | ||
} | ||
|
||
verRemote, err := versionutil.ParseGeneric(remoteVersion) |
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.
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.
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 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.
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.
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.
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.
sounds good! thanks.
/retest |
…301-origin-release-1.12 Automated cherry pick of #69301: kubeadm: handle stable-1 as the default version
What this PR does / why we need it:
The default version in kubeadm is now
stable-1
. This willpull a version from the
stable-1.txt
endpoint which mightend 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:
Release note:
/kind bug
/assign @kad @timothysc
@kubernetes/sig-cluster-lifecycle-pr-reviews