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
Add warning if client/server version difference exceeds the supported skew #98250
Conversation
549b63c
to
7976208
Compare
/assign @brendandburns |
/cc |
/cc |
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.
Left some comments just as a second opinion :)
8982e74
to
3d1a258
Compare
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 have few comments. However, I must say: LGTM.
if supported, err := isWithinSupportedVersionSkew(clientVersion, serverVersion); err != nil { | ||
return err | ||
} else if !supported { | ||
fmt.Fprintf(w, "WARNING: version difference between client (%s.%s) and server (%s.%s) exceeds the supported minor version skew of +/-%d\n", |
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.
Maybe it's only me but I think +/- in a statement is a little confusing. However, I don't have a better suggestion, sorry.
WARNING: version difference between client (1.21+) and server (1.18) exceeds the supported minor version skew of +/-1
Another question users might have: "Right, so now I have the warning of version skew, what should I do ?"
Maybe add: "It is recommended to keep upgrading client and server with the same version." (or similar/improved msg)
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, I don’t really know what else to say here. It’s really not horrible to use an out of skew client, but if you are running into problems, you should be aware that it could be an unsupported skew.
A main reason for adding this warning is to make people aware of the unsupported skew before they open an issue in the kubectl repo.
but you’re right, it is not super actionable.
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.
Hey @briandorsey I believe the warning you created is super valid but it's difficult to avoid users to open issues with unsupported skew IMO.
Probably we might have such scenarios with users out there:
- didn't understand the message - what's skew +/- 1?
- simple ignore it as they don't know what to do next
- not sure "how to fix it"
- not sure "how to make the cluster in a minimum good shape" to open the issue.
From my side, the code looks great but I would request more people to review the message to have more ideas. Probably a good PR for request ideas in the SIG-CLI meeting.
82ff0e2
to
7b3d7aa
Compare
/test pull-kubernetes-verify |
Thanks to a comment @soltysh left in another PR, I became aware of the existence of ParseSemantic in api machinery. I updated this PR to use this to get the major and minor versions instead of reinventing the wheel, so to speak. |
@dougsland See my comment above, I was able to re-use an existing function to get major/minor version, so the code has changed. Can you take another look? Thanks! |
/assign |
/milestone v1.21 |
/triage accepted |
staging/src/k8s.io/kubectl/pkg/cmd/version/skew_warning_test.go
Outdated
Show resolved
Hide resolved
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 looks good to me. I actually think the warning message is about as good as it can be. I've added the v1.21 milestone, since we hope to get this in by code freeze. I can LGTM once Maciej is happy (and the BUILD file is removed).
7b3d7aa
to
0c28cad
Compare
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
/approve
"io" | ||
"k8s.io/apimachinery/pkg/util/version" | ||
apimachineryversion "k8s.io/apimachinery/pkg/version" | ||
"math" |
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.
Nit: but try to keep imports split into:
- built-in
- 3rd party
- k8s
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brianpursley, seans3, soltysh 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 |
/retest |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR writes a warning message to stderr when you run
kubectl version
if the version skew between the client and server is more than the supported skew (+/- 1 minor version).Example warning message:
Which issue(s) this PR fixes:
kubernetes/kubectl#685
Special notes for your reviewer:
The approach of only warning when the user runs
kubectl version
was discussed at the 1/13/2021 SIG-CLI meeting.Long-term we may want to introduce a more intrusive warning to alert users of an unsupported skew, but that is beyond the scope of this PR.
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: