Skip to content

Conversation

@Xartos
Copy link
Contributor

@Xartos Xartos commented Jan 10, 2025

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:

When reordering controlplane nodes in inventory.ini and the first in the list is not the same as the first one when running kubectl get nodes --selector=node-role.kubernetes.io/control-plane -o json you'll get an error:

fatal: [some-name-k8s-control-plane-6]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'kubeadm_certificate_key' is undefined. 'kubeadm_certificate_key' is undefined"}

This is because the variable first_kube_control_plane is ultimately set using kubectl and this is the one that is used to create the certificate.
However the one after is using groups['kube_control_plane'][0] which will depend on what node is first in inventory.ini hence why this error occurs.

This PR changes so the parsing also fetches the certificate from the first_kube_control_plane.

Which issue(s) this PR fixes:

Fixes #10973

Special notes for your reviewer:

All credit to @nvalembois who had this patch in #10973

Does this PR introduce a user-facing change?:

Fix a bug where `kubeadm_certificate_key` was not defined if control plane nodes were not in correct order 

@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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 10, 2025
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 10, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @Xartos. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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-sigs/prow repository.

@VannTen
Copy link
Contributor

VannTen commented Jan 10, 2025

Hum, if @nvalembois wrote the patch, maybe we should put it as author in the commit ? and I'm not sure how that interacts with the k-sigs CLA stuff ?
@yankay know anything about that ?
/ok-to-test

@k8s-ci-robot k8s-ci-robot added 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 10, 2025
@Xartos
Copy link
Contributor Author

Xartos commented Jan 10, 2025

Hum, if @nvalembois wrote the patch, maybe we should put it as author in the commit ? and I'm not sure how that interacts with the k-sigs CLA stuff ? @yankay know anything about that ? /ok-to-test

Right, yea if it's easier then @nvalembois is free to create another PR instead of me and I'll close this one. As long as we get the fix then I'm happy

@VannTen
Copy link
Contributor

VannTen commented Jan 10, 2025 via email

@Xartos Xartos force-pushed the fli/fix-controlplane-reordering branch from 7ca8483 to daad54a Compare January 10, 2025 10:36
@Xartos
Copy link
Contributor Author

Xartos commented Jan 10, 2025

Hmm, can't seem to see any details on what the CLA action looked at now so I can't tell. But let's see if @yankay knows

@VannTen
Copy link
Contributor

VannTen commented Jan 14, 2025 via email

@Xartos Xartos force-pushed the fli/fix-controlplane-reordering branch from daad54a to ef2a92c Compare January 14, 2025 15:18
@VannTen
Copy link
Contributor

VannTen commented Jan 14, 2025

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: VannTen, Xartos

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 14, 2025
@k8s-ci-robot k8s-ci-robot merged commit 5ca23e3 into kubernetes-sigs:master Jan 14, 2025
43 checks passed
@Xartos Xartos deleted the fli/fix-controlplane-reordering branch January 15, 2025 07:03
root-expert pushed a commit to camelotls/kubespray that referenced this pull request May 21, 2025
@VannTen
Copy link
Contributor

VannTen commented Dec 2, 2025

/cherrypick release-2.27

@k8s-infra-cherrypick-robot

@VannTen: new pull request created: #12758

In response to this:

/cherrypick release-2.27

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-sigs/prow repository.

VannTen added a commit to VannTen/kubespray that referenced this pull request Dec 2, 2025
Before "5ca23e3bf (Changed to use first_kube_control_plane to parse
kubeadm_certificate_key (kubernetes-sigs#11875), 2025-01-14)", kubespray would have
problem adding new control planes when the order of the nodes in kubectl
output and the ansible inventory were not the same.

But the underlying problem is that the operation is fundamentally
something that should be done only once, and recorded for all host in
play.

Since `register` and `sef_fact` when used with `run_once` set the
variable for all the hosts, use it. Also allows to use the variable
directly instead of relying on hostvars to make the task more readable.
k8s-ci-robot pushed a commit that referenced this pull request Dec 8, 2025
Before "5ca23e3bf (Changed to use first_kube_control_plane to parse
kubeadm_certificate_key (#11875), 2025-01-14)", kubespray would have
problem adding new control planes when the order of the nodes in kubectl
output and the ansible inventory were not the same.

But the underlying problem is that the operation is fundamentally
something that should be done only once, and recorded for all host in
play.

Since `register` and `sef_fact` when used with `run_once` set the
variable for all the hosts, use it. Also allows to use the variable
directly instead of relying on hostvars to make the task more readable.
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to add control-plane node

4 participants