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: fix a regression in "kubeadm init" where --kubeconfig is ignored #122735

Merged
merged 1 commit into from Jan 15, 2024

Conversation

avorima
Copy link
Contributor

@avorima avorima commented Jan 12, 2024

What type of PR is this?

/kind bug
/kind regression

What this PR does / why we need it:

Don't create admin rolebindings when --kubeconfig is set to a non-default value.
This allows kubeadm init to be invoked with a custom kubeconfig again.

Which issue(s) this PR fixes:

Fixes kubernetes/kubeadm#2992

Special notes for your reviewer:

I built and tested the kubeadm binary.

@neolit123

Does this PR introduce a user-facing change?

fixes a 1.29 regression in "kubeadm init" that caused a user-specified --kubeconfig file to be ignored.

@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/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/regression Categorizes issue or PR as related to a regression from a prior release. 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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 12, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @avorima. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Jan 12, 2024
@k8s-ci-robot k8s-ci-robot added area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 12, 2024
Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

/hold for review
/cc @SataQiu

/ok-to-test

Comment on lines 384 to 397
// This only works if the client that is constructed from the kubeconfig is not used.
if _, err := data.Client(); err != nil {
t.Fatalf("data.Client returned unexpected 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.

can we actually verify that the initOptions.kubeconfigPath is used here?
one way would be with httptest, i guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

something like this?

	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if r.Method != http.MethodHead {
			w.WriteHeader(http.StatusMethodNotAllowed)
		}
	}))
	defer ts.Close()

...

	result := client.Discovery().RESTClient().Verb("HEAD").Do(context.Background())
	if err := result.Error(); err != nil {
		t.Fatalf("REST client request returned unexpected error: %v", err)
	}

Copy link
Member

@neolit123 neolit123 Jan 12, 2024

Choose a reason for hiding this comment

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

SGTM!

(please keep the commits squashed to 1)

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 12, 2024
@neolit123
Copy link
Member

/triage accepted
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed 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. labels Jan 12, 2024
@neolit123
Copy link
Member

/release-note-edit

kubeadm: fix a regression in "kubeadm init" that caused a user-specified --kubeconfig file to be ignored.

@neolit123
Copy link
Member

/uncc @chendave

@k8s-ci-robot k8s-ci-robot removed the request for review from chendave January 12, 2024 15:32
@neolit123
Copy link
Member

please squash the commits to 1
/approve

leaving LGTM to @SataQiu
do you think this is good, as is and we can backport it?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Jan 12, 2024
Don't create admin rolebindings when --kubeconfig is set to a
non-default value.

Fixes: kubernetes/kubeadm#2992

Signed-off-by: Mario Valderrama <mario.valderrama@ionos.com>
@neolit123
Copy link
Member

/retitle kubeadm: fix a regression in "kubeadm init" where --kubeconfig is ignored

@k8s-ci-robot k8s-ci-robot changed the title Fix kubeadm init regression kubeadm: fix a regression in "kubeadm init" where --kubeconfig is ignored Jan 12, 2024
@avorima
Copy link
Contributor Author

avorima commented Jan 15, 2024

I suppose this change won't make it into 1.29.1, right? @neolit123 @SataQiu
https://kubernetes.io/releases/patch-releases/

@neolit123
Copy link
Member

neolit123 commented Jan 15, 2024

I suppose this change won't make it into 1.29.1, right? @neolit123 @SataQiu https://kubernetes.io/releases/patch-releases/

no, we missed the deadline last friday.
it can land in .2

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

/lgtm

let's go ahead and merge this.
it can catch the next cherry pick deadline
https://kubernetes.io/releases/patch-releases/#upcoming-monthly-releases

@avorima
would you like to send the cherry pick for release-1.29 as well?
you can try https://github.com/kubernetes/kubernetes/blob/master/hack/cherry_pick_pull.sh
if not a manual cherry pick PR can work too.

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

LGTM label has been added.

Git tree hash: e56cdeb6ce3d57987755569b24c0dc84eea1214b

@neolit123
Copy link
Member

/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 Jan 15, 2024
@avorima
Copy link
Contributor Author

avorima commented Jan 15, 2024

sure, i'll do the cherry pick

@k8s-ci-robot k8s-ci-robot merged commit 789e029 into kubernetes:master Jan 15, 2024
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.30 milestone Jan 15, 2024
@avorima avorima deleted the fix-kubeadm-regression-2992 branch January 15, 2024 17:51
@liggitt
Copy link
Member

liggitt commented Feb 8, 2024

Thanks for the PR, please update the release note with the minor version the regression was introduced (for example, "fixes a 1.29 regression…")

@liggitt
Copy link
Member

liggitt commented Feb 8, 2024

And update the release note in the cherry-pick(s) as well

@avorima
Copy link
Contributor Author

avorima commented Feb 8, 2024

@liggitt Thanks for you feedback. I updated both release notes

k8s-ci-robot added a commit that referenced this pull request Feb 8, 2024
…735-upstream-release-1.29

Automated cherry pick of #122735: Fix kubeadm init regression
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. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. 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/M Denotes a PR that changes 30-99 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.

kubeadm init phase bootstrap-token ignores --kubeconfig in 1.29
4 participants