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

Tighten kubectl version check #42600

Closed

Conversation

caesarxuchao
Copy link
Member

@caesarxuchao caesarxuchao commented Mar 6, 2017

Fix #40813

This let api server apply the workaround added in #35840 only for kubectl version >=1.3.0 and <1.5.0.

Note that if a kubectl is built from a commit between 1.3.0 and 1.50 in the master branch, kubectl will have version kubectl/v0.0.0, so the workaround will not be applied and such kubectl will suffer #35791. I think that's a less evil bug than #40813, thus we should merge this pull.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 6, 2017
@k8s-github-robot
Copy link

This PR is not for the master branch but does not have the cherrypick-approved label. Adding the do-not-merge label.

@k8s-github-robot k8s-github-robot added do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note-label-needed labels Mar 6, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@foxish
Copy link
Contributor

foxish commented Mar 6, 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 Mar 6, 2017
Copy link
Member

@liggitt liggitt left a comment

Choose a reason for hiding this comment

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

why wouldn't we tightly bound the versions the workaround applies to? (>= 1.4.0, <1.5.0)

Are we also fixing the v0.0.0 issue in head?

@caesarxuchao caesarxuchao changed the title Treat v0.0.0 as the latest version Tighten kubectl version check Mar 7, 2017
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 7, 2017
@caesarxuchao
Copy link
Member Author

why wouldn't we tightly bound the versions the workaround applies to? (>= 1.4.0, <1.5.0)

Thanks, i updated the code as suggested. Also updated the PR description. PTAL.

Are we also fixing the v0.0.0 issue in head?

i think it has always been like this. Only when we make a release will the version be written to base.go, so it's not a bug.

@liggitt
Copy link
Member

liggitt commented Mar 7, 2017

Are we also fixing the v0.0.0 issue in head?

i think it has always been like this. Only when we make a release will the version be written to base.go, so it's not a bug.

I don't think it has always been like that. Building from a branch off of master just before the release-1.5 branch was cut (a3ba760) with a random commit of my own added on top, I get

User-Agent: kubectl/v1.5.0 (darwin/amd64) kubernetes/a3ba760

the issue might be that the build scripts only set vars under k8s.io/kubernetes/pkg/version, and once we switched to the client-go base.go, it stopped getting dynamic vars

kube::version::ldflag() {
  local key=${1}
  local val=${2}

  echo "-X ${KUBE_GO_PACKAGE}/pkg/version.${key}=${val}"
}

// TODO: Remove in 1.6. Returns if kubectl is older than v1.5.0
func isOldKubectl(userAgent string) bool {
// TODO: Remove in 1.6. Returns if kubectl is older than v1.5.0 and newer than or equal to v1.4.0
func is14Kubectl(userAgent string) bool {
// example userAgent string: kubectl-1.3/v1.3.8 (linux/amd64) kubernetes/e328d5b
Copy link
Member

Choose a reason for hiding this comment

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

funnily, the example user agent string no longer passes this function

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to "1.4". Though as an example it doesn't have to pass the check :)

@caesarxuchao
Copy link
Member Author

Thanks @liggitt. Tried the following and the rewrite still doesn't work:

echo "-X ${KUBE_GO_PACKAGE}/pkg/version.${key}=${val} -X k8s.io/client-go/pkg/version.${key}=${val} -X vendor/k8s.io/client-go/pkg/version.${key}=${val} -X staging/src/k8s.io/client-go/pkg/version.${key}=${val}"

@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 7, 2017
@liggitt
Copy link
Member

liggitt commented Mar 7, 2017

Thanks @liggitt. Tried the following and the rewrite still doesn't work:

echo "-X ${KUBE_GO_PACKAGE}/pkg/version.${key}=${val} -X k8s.io/client-go/pkg/version.${key}=${val} -X vendor/k8s.io/client-go/pkg/version.${key}=${val} -X staging/src/k8s.io/client-go/pkg/version.${key}=${val}"

The go path is k8s.io/kubernetes/vendor/k8s.io/client-go/...

building from HEAD with this:

  echo "-X ${KUBE_GO_PACKAGE}/pkg/version.${key}=${val}"
  echo "-X ${KUBE_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.${key}=${val}"

produces

User-Agent: kubectl/v1.7.0 (darwin/amd64) kubernetes/4c4c9e4

@liggitt
Copy link
Member

liggitt commented Mar 7, 2017

opened #42623 with the build fix

@liggitt
Copy link
Member

liggitt commented Mar 7, 2017

if we get #42623 merged, I don't feel strongly about patching this version check

@caesarxuchao
Copy link
Member Author

@liggitt may i get the lgtm? Thanks.

@liggitt
Copy link
Member

liggitt commented Mar 7, 2017

in the abstract, the bounded version check LGTM, given the v0.0.0 issue is a bug we can fix, I'm unsure whether it's worth updating the 1.5 release for that

@caesarxuchao
Copy link
Member Author

Hmm, let's still merge this. It's a pure improvement. We might break kubectl again, this pull will save people from debugging the issue again.

@liggitt
Copy link
Member

liggitt commented Mar 7, 2017

did the previous unbounded check allow kubectl 1.3 to work against 1.5?

@caesarxuchao
Copy link
Member Author

1.5 apiserver will hide the apps and the policy groups from 1.3 kubectl, so 1.3 kubectl apiversions won't see those two groups. Other than this, 1.3 kubectl works.

@liggitt
Copy link
Member

liggitt commented Mar 7, 2017

so tightening it breaks kubectl 1.3, which is outside our 1 version skew support statement, but makes this not a pure improvement. I could go either way.

@caesarxuchao
Copy link
Member Author

Excuse my English, I used the wrong tense. I mean without the tightening, "1.5 apiserver is hiding the apps and the policy groups from 1.3 kubectl, so 1.3 kubectl apiversions doesn't see those two groups." With the tightening, 1.3 kubectl can see these two groups enabled, though it still cannot do any CRUD operations because the lack of the scheme. So this pull is a pure improvement.

@liggitt
Copy link
Member

liggitt commented Mar 7, 2017

ok, so 1.4 was the only version that had the "already registered" problem?

@caesarxuchao
Copy link
Member Author

caesarxuchao commented Mar 7, 2017

Sorry,1.3 is affected by the "already registered" change, 1.2 is not. We should tighten the version to >=1.3 and <1.5.

[update] I've updated the code.

(the line caused the bug is merged on Mar. 31, 2016: #18835)

@liggitt liggitt added this to the v1.5 milestone Mar 11, 2017
@liggitt liggitt added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Mar 11, 2017
@liggitt
Copy link
Member

liggitt commented Mar 11, 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 Mar 11, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

The following people have approved this PR: caesarxuchao, foxish, liggitt

Needs approval from an approver in each of these OWNERS Files:

We suggest the following people:
cc @smarterclayton
You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@caesarxuchao
Copy link
Member Author

@mwielgus I think you are managing the 1.5 branch, could you approve this pr to the 1.5 branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants