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: move show-join-command as a separate phase #111512

Merged
merged 1 commit into from Aug 27, 2022

Conversation

SataQiu
Copy link
Member

@SataQiu SataQiu commented Jul 28, 2022

What type of PR is this?

/kind bug
/kind feature

What this PR does / why we need it:

kubeadm: move show-join-command as a separate phase

Which issue(s) this PR fixes:

Fixes kubernetes/kubeadm#2734

Special notes for your reviewer:

Does this PR introduce a user-facing change?

kubeadm: "show-join-command" has been added as a new separate phase at the end of "kubeadm init". You can skip printing the join information by using "kubeadm init --skip-phases=show-join-command". Executing only this phase on demand will throw an error because the phase needs dependencies such as bootstrap tokens to be pre-populated.

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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. kind/feature Categorizes issue or PR as related to a new feature. 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. labels Jul 28, 2022
@k8s-ci-robot
Copy link
Contributor

@SataQiu: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 needs-priority Indicates a PR lacks a `priority/foo` label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. labels Jul 28, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jul 28, 2022
@SataQiu SataQiu force-pushed the fix-kubeadm-20220728 branch 3 times, most recently from a7b1e24 to 1647f78 Compare July 28, 2022 15:28
@@ -96,11 +96,12 @@ func NewBootstrapTokenStringFromIDAndSecret(id, secret string) (*BootstrapTokenS

// BootstrapTokenToSecret converts the given BootstrapToken object to its Secret representation that
// may be submitted to the API Server in order to be stored.
func BootstrapTokenToSecret(bt *BootstrapToken) *v1.Secret {
func BootstrapTokenToSecret(bt *BootstrapToken, labels map[string]string) *v1.Secret {
Copy link
Member

Choose a reason for hiding this comment

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

hm, i know this function is just for kubeadm use mainly but with this change we are modifying the signature. its a breaking change in a v1 package.

Copy link
Member

Choose a reason for hiding this comment

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

we could introduce a new function called BootstrapTokenToSecretWithLabels

Copy link
Member Author

Choose a reason for hiding this comment

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

Based on our previous discussion, maybe we shouldn't support separate calls kubeadm init phase show-join-command. Because it has a strong dependence on BootstrapToken and UploadCerts phases.
Our current workflow framework does not support dependency checking, and perhaps we need to re-evaluate whether this is necessary... @neolit123

Copy link
Member

Choose a reason for hiding this comment

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

if we are adding the phase it makes sense to support calling it as a CLI, but i think we should just error out because the dependencies are not there. i guess the main purpose would be for users to be able to skip it

Copy link
Member Author

Choose a reason for hiding this comment

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

In order to implement dependency verification, I introduce a new field Dependencies for Phase.
I think this is fine, because it is not a break change, the original behavior will not be affected.
What do you think? @neolit123

Copy link
Member Author

@SataQiu SataQiu Aug 26, 2022

Choose a reason for hiding this comment

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

If you run kubeadm init phase show-join-command, the error output will be something like this:

unresolved dependencies:
	missing [bootstrap-token upload-certs] phase(s) needed by "show-join-command" phase

Copy link
Member

@neolit123 neolit123 Aug 26, 2022

Choose a reason for hiding this comment

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

i think one problem with the dependencies concept is how do users execute dependencies? it is technically not possible to run two phases one after another to solve the dependencies problem. they can only skip all phases except the target phase and it's dependencies.

but overall i think this is mostly OK.

@SataQiu
Copy link
Member Author

SataQiu commented Jul 28, 2022

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 28, 2022
@SataQiu SataQiu changed the title kubeadm: moving showJoinCommand as a separate phase kubeadm: move showJoinCommand as a separate phase Aug 26, 2022
@SataQiu SataQiu changed the title kubeadm: move showJoinCommand as a separate phase kubeadm: move show-join-command as a separate phase Aug 26, 2022
}
for _, dep := range p.Phase.Dependencies {
if _, ok := visited[dep]; !ok {
return errors.Errorf("unresolved dependencies: missing %q phase which is needed by %q phase", dep, p.Phase.Name)
Copy link
Member

@neolit123 neolit123 Aug 26, 2022

Choose a reason for hiding this comment

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

we could add all the missing dependencies in a new slice and print it with %v, then return a single error

it would look like [a , b]

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, the output will be:

unresolved dependencies:
	missing [bootstrap-token upload-certs] phase(s) needed by "show-join-command" phase

cmd/kubeadm/app/cmd/phases/workflow/phase.go Outdated Show resolved Hide resolved
@neolit123
Copy link
Member

release note:

kubeadm: show-join-command has been a separate phase, users can skip printing the join information by using kubeadm init --skip-phases=show-join-command

suggesting minor change to:

kubeadm: "show-join-command" has been added as a new separate phase at the end of "kubeadm init". You can skip printing the join information by using "kubeadm init --skip-phases=show-join-command". Executing only this phase on demand will throw an error because the phase needs dependencies such as bootstrap tokens to be pre-populated.

please adjust further if needed.

@SataQiu SataQiu force-pushed the fix-kubeadm-20220728 branch 2 times, most recently from dc59381 to 621e610 Compare August 26, 2022 15:34
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
/approve

thanks @SataQiu

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@SataQiu
Copy link
Member Author

SataQiu commented Aug 27, 2022

/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 Aug 27, 2022
@k8s-ci-robot k8s-ci-robot merged commit 065a761 into kubernetes:master Aug 27, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Aug 27, 2022
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/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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubeadm init can't skip all phases
3 participants