Skip to content

node-label: retry "Set label to node" while the Node object registers - #13621

Open
romaincabassot wants to merge 1 commit into
kubernetes-sigs:masterfrom
romaincabassot:node-label-retry
Open

romaincabassot wants to merge 1 commit into
kubernetes-sigs:masterfrom
romaincabassot:node-label-retry

Conversation

@romaincabassot

Copy link
Copy Markdown

What type of PR is this?

/kind bug

What this PR does / why we need it:

The kubernetes/node-label role labels nodes with kubectl label node ... right after the kubernetes/kubeadm role. kubeadm join returns once the kubelet's bootstrap CSR is signed, but the kubelet then has to switch to its new client certificate and register the Node object, which happens asynchronously. On a fresh install / scale-up (and on slower VMs or a busy apiserver) the label task can therefore run before the Node exists and fail the whole play (any_errors_fatal):

failed: [node4 -> node1] (item=livesp/netflow-node=true) => {"cmd": ["kubectl", "label", "node", "node4", "livesp/netflow-node=true", "--overwrite=true"],
  "rc": 1, "stderr": "Error from server (NotFound): nodes \"node4\" not found"}

Timeline from a real failing run (kubespray v2.30.0, 5-node cluster, Kubernetes 1.34): kubeadm join on node4 returned rc=0 at 15:58:28.2 ("This node has joined the cluster"), and kubectl label node node4 hit NotFound at 15:58:32.7, about 4 seconds later. The other nodes were labelled fine in the same step, which is why the failure is intermittent.

The task has no retries/until (the role only waits for the apiserver /healthz, not for the Node to exist). This PR adds a retry (10 x 6s, the same budget as the healthz wait), and only when the error is NotFound; any other failure (e.g. an invalid label) still fails immediately.

Which issue(s) this PR is related to:

Related to #12779 (same symptom, nodes "..." not found in Set label to node; that report attributes it to CNI initialisation on scale.yml, this PR addresses the generic "Node not registered yet" window). I did not use "Fixes" since the root cause in that issue may differ.

Special notes for your reviewer:

Only the NotFound case is retried so real configuration errors are not delayed. I did not run the full CI matrix locally; the change was validated by parsing the task YAML and by analysing the failing run's timestamps.

Does this PR introduce a user-facing change?

node-label: retry `kubectl label node` on `NotFound` so labelling no longer fails when the kubelet has not registered the Node yet

AI usage disclosure:

YES. The root-cause analysis and the patch were prepared with Claude Code (Claude Sonnet 5.5) and reviewed and submitted by the author, who is responsible for the change.

@kubernetes-prow kubernetes-prow Bot 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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 8, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @romaincabassot!

It looks like this is your first PR to kubernetes-sigs/kubespray 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kubespray has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: romaincabassot
Once this PR has been reviewed and has the lgtm label, please assign yankay for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

@kubernetes-prow kubernetes-prow Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 8, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @romaincabassot. 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.

Details

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.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

CLA Missing ID

  • ✅ login: romaincabassot / name: Romain Cabassot (9d1c71b)
  • ❌ The email address for the commit (9d1c71b) is not linked to the GitHub account, preventing the EasyCLA check. Consult this Help Article and GitHub Help to resolve. (To view the commit's email address, add .patch at the end of this PR page's URL.) For further assistance with EasyCLA, please visit our EasyCLA portal and chat with our support bot.

One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:

Co-authored-by: name <email>

Supported Co-authored-by: formats include:

  1. Anything <id+login@users.noreply.github.com> - it will locate your GitHub user by id part.
  2. Anything <login@users.noreply.github.com> - it will locate your GitHub user by login part.
  3. Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
  4. Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
  5. login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.

Alternatively, if the co-author should not be included, remove the Co-authored-by: line from the commit message.

Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:

/easycla

@kubernetes-prow
kubernetes-prow Bot requested review from VannTen and tico88612 October 8, 2026 15:19
@kubernetes-prow kubernetes-prow Bot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Oct 8, 2026
The Node object is created asynchronously by the kubelet after
`kubeadm join` returns, so on a fresh install or scale-up the
`kubectl label` call can run before the node is registered and fail
with `Error from server (NotFound): nodes "<name>" not found`.

Retry the task (10 times, 6s apart, same budget as the apiserver
healthz wait earlier in the role), and only when the failure is a
NotFound; any other error still fails immediately.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@romaincabassot

Copy link
Copy Markdown
Author

/easycla

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it 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.

1 participant