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

Add warning if client/server version difference exceeds the supported skew #98250

Merged
merged 1 commit into from Mar 4, 2021

Conversation

brianpursley
Copy link
Member

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:

WARNING: version difference between client (1.21+) and server (1.19) exceeds the supported minor version skew of +/-1

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

kubectl version changed to write a warning message to stderr if the client and server version difference exceeds the supported version skew of +/-1 minor version.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. 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. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubectl labels Jan 21, 2021
@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 21, 2021
@brianpursley brianpursley force-pushed the kubectl-685 branch 2 times, most recently from 549b63c to 7976208 Compare January 21, 2021 13:30
@brianpursley
Copy link
Member Author

/assign @brendandburns

@dougsland
Copy link
Member

/cc

@rikatz
Copy link
Contributor

rikatz commented Jan 24, 2021

/cc

Copy link
Contributor

@rikatz rikatz left a 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 :)

@brianpursley brianpursley force-pushed the kubectl-685 branch 2 times, most recently from 8982e74 to 3d1a258 Compare January 25, 2021 00:49
Copy link
Member

@dougsland dougsland left a 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.

staging/src/k8s.io/kubectl/pkg/cmd/version/skew_warning.go Outdated Show resolved Hide resolved
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",
Copy link
Member

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)

Copy link
Member Author

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.

Copy link
Member

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.

staging/src/k8s.io/kubectl/pkg/cmd/version/skew_warning.go Outdated Show resolved Hide resolved
@brianpursley brianpursley force-pushed the kubectl-685 branch 2 times, most recently from 82ff0e2 to 7b3d7aa Compare February 13, 2021 19:05
@brianpursley
Copy link
Member Author

/test pull-kubernetes-verify

@brianpursley
Copy link
Member Author

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.

@brianpursley
Copy link
Member Author

@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!

@soltysh
Copy link
Contributor

soltysh commented Mar 3, 2021

/assign

@seans3
Copy link
Contributor

seans3 commented Mar 3, 2021

/milestone v1.21
/priority important-soon

@k8s-ci-robot k8s-ci-robot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Mar 3, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Mar 3, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Mar 3, 2021
@seans3
Copy link
Contributor

seans3 commented Mar 3, 2021

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 3, 2021
Copy link
Contributor

@seans3 seans3 left a 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).

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 3, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 4, 2021
Copy link
Contributor

@soltysh soltysh left a 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"
Copy link
Contributor

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:

  1. built-in
  2. 3rd party
  3. k8s

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 4, 2021
@k8s-ci-robot
Copy link
Contributor

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

@soltysh
Copy link
Contributor

soltysh commented Mar 4, 2021

/retest

@k8s-ci-robot k8s-ci-robot merged commit d2d9b0e into kubernetes:master Mar 4, 2021
@brianpursley brianpursley deleted the kubectl-685 branch February 2, 2023 01:20
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/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants