fix: retry bootstrap completion when the annotation write fails #508
<span aria-hidden="true">👷</span> Deploy request for node-readiness-controller pending review.
Visit the deploys page to approve it
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 08c22a875757a021ae4fe521c42ab7c4ecca0f9d |
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: <a href="https://github.com/kubernetes-sigs/node-readiness-controller/pull/508#" title="Author self-approved">lkhun9311</a>
Once this PR has been reviewed and has the lgtm label, please assign sergeykanzhelev for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
<details open>
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
</details>
<!-- META={"approvers":["sergeykanzhelev"]} -->
Welcome @lkhun9311! <br><br>It looks like this is your first PR to <a href='https://github.com/kubernetes-sigs/node-readiness-controller'>kubernetes-sigs/node-readiness-controller</a> 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval. <br><br>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. <br><br>You can also check if kubernetes-sigs/node-readiness-controller has its own contribution guidelines. <br><br>You may want to refer to our testing guide if you run into trouble with your tests not passing. <br><br>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! <br><br>Thank you, and welcome to Kubernetes. :smiley:
Hi @lkhun9311. 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.
</details>
looks reasonable to me.
/cc @Karthik-K-N
Nice catch, Thanks for the PR
/lgtm
Thanks @Karthik-K-N. @ajaysundark, when you have a moment, could you add ok-to-test and approve if it still looks right to you?
Why not return the error directly inside err != nil case? That felt more idiomatic to me.
nit: 'bootstrap as completed' is probably what you wanted to write
rest LGTM to merge.
@AnuragThePathak, thanks for the careful review.
Done in 08c22a8: the err != nil case now returns the error itself, and the function returns nil after the other cases.
Fixed: the message now reads "failed to mark bootstrap as completed", and the test that checks it is updated.
LGTM you can mark the conversations as resolved
@Karthik-K-N I pushed a small change for @AnuragThePathak's review, and that removed the lgtm. Could you take another look?
@ajaysundark, an ok-to-test when you have a moment would be great.
/ok-to-test
/test pull-node-readiness-controller-verify-all
/lgtm
Karthik-K-N
lkhun9311
Description
For a
bootstrap-onlyrule, when a node satisfies the conditions and has no rule taint,evaluateRuleForNodeonly writes thebootstrap-completedannotation throughmarkBootstrapCompleted. That helper logged a failed write and incrementedfailures_total{reason="AnnotationPatchFailed"}, but returned nothing. The evaluation was recorded as a success, the node was not infailedNodes, and the failure did not itself schedule a retry. If the condition later went unsatisfied, the rule tainted a node that had already bootstrapped.markBootstrapCompletednow returns the error, and thedefaultbranch ofevaluateRuleForNodereturns it asfailed to mark bootstrap completed: .... Both reconcilers already handle an evaluation error: they record the node infailedNodeswith reasonEvaluationError, incrementfailures_total{reason="EvaluationError"}, and requeue with backoff, the same as a failed taint patch. The helper's own log line andAnnotationPatchFailedcounter, and the deferral when the taint is still present, are unchanged.Related Issue
Fixes #507
Type of Change
/kind bug
Testing
node_controller_test.go: a ready, untainted node on a fake client whose patches return Forbidden.evaluateRuleForNodemust return the wrapped Forbidden error, record no evaluation, and leave no annotation. Without the change innodereadinessrule_controller.goit fails withExpected an error to have occurred.markBootstrapCompletedin the tests now check the returned error.make test,make lint(0 issues) andhack/verify-all.shpass.failedNodeswithfailed to mark bootstrap completed: nodes "nrc-gpu-worker" is forbidden .... After the role is restored, a retry writes the annotation, and setting the condition toFalseleaves the node untainted. Onmainthe same steps leave no annotation and the node gets tainted.Checklist
make testpassesmake lintpassesDoes this PR introduce a user-facing change?
``
release-note
``bootstrap-only rules now report a failed bootstrap-completion annotation write in status.failedNodes and requeue the reconcile with backoff. Previously the failure was recorded as a successful evaluation and did not itself schedule another attempt, so a later condition change could taint a node that had already bootstrapped.
Generative AI Usage Disclosure
How they were used:
An AI coding agent drafted the fix and the test. I reviewed the change and the test results.