Add RuleEvaluationSummary to NodeReadinessRule status and CRD #502
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #502"
general
weight: 0.35
ajaysundark
<!-- Thanks for sending a pull request! Here are some tips for you:
-->
Description
Currently the NodeReadinessRule reports the impact of the rule across the cluster through the nodeEvaluations field. For people leveraging prometheus, there are metrics to provide that information numerically. However, there's no numerical representation of that for kubectl users, or someone using tools like Lens. While working on Headlamp also we had this exact requirement and we ended up iterating through the nodeEvaluations array to calculate this information per rule.
This PR addresses that gap, by introducing an evaluationSummary field in NodeReadinessRule status. The RuleEvaluationSummary struct contains 3 integer fields -
Targeted = Satisfied + Unsatisfied
Also added Kubebuilder printcolumns to display Targeted and Satisfied (priority=1) in
kubectl get nrr -o wide.This paves a clear pathway for deprecation of nodeEvaluations field in combination with NRE. NRE provides fine-tuned Node level evaluation results, while RuleEvaluationSummary provides rule specific evaluation results statistics. FailedNodes is yet another unaddressed area still.
Trade-offs considered
Originally proposed idea in #484, explored around the idea of using nodeEvaluation to calculate the summary on the fly inside
processAllNodesForRuleandprocessNodeAgainstAllRules. After that there was another evolution to populate the satisfied and unsatisfied stats from spec directly and using nodeFailure for the failure count. Both these methods had a serious drawback of triggering O(n) loop for every node event and O(n) status write risk for n node events.This experience led us to look for references in upstream projects -
Why we went with Debounced Workqueue Coalescing pattern: Our constraints were 5k nodes at max and a humanly manageable number of rules, and it seemed like per node event, it would be highly optimal to map nodes to applicable rules and queue the rules combined with coalescing rules in the queue over a 1-2 second window.
O(n) node iteration for evaluation is still there but when you limit the frequency and consider the other constraints, it no longer remains the bottleneck rather the etcd API write to update the rule status. This was convincing enough to not to opt for the Kueue style pattern.
How we adopted it here:
It was identified that rule reconciler should be in charge of writing to rules. As part of that, the rule reconciler was configured to have a secondary watch on the node resources with appropriate predicates to filter out the noise, then perform node to rule mapping and queue the rules for reconciliation but with TypedDelayingInterface.AddAfter which puts a handbrake on the standard rate at which reconciliation happens and allows duplicate queue items to merge. For now we have resorted to a window of 2 seconds, considering the fact the evaluation summary is meant for human inspection purpose mainly.
Also because we had to accommodate the change within the existing reconcile method for Rule Reconciler, we used check on
Generation != ObservedGenerationto detect whether it is triggered by pre-existing Rule GenerationChangedPredicate event or the new Node events. In case we find the spec has changed (Generation != ObservedGeneration) we follow the existing flow, accompanied by RuleEvaluationSummary computation which ends up in a single status write anyway for the whole updated status. If it's not a Rule GenerationChangedPredicate event, then we compute the RuleEvaluationSummary only and write the status to etcd and complete the reconciliation process. In case of merger of a node event driven reconciliation request and rule GenerationChangedPredicate driven request, the first path is taken and it's intentional only.Also it may be worth noting that, we avoid API status write for the summary only path when there's no changes in the counts of any field.
There is also a new method named nodeSatisfiesRule been added with this PR, which actually may be useful for avoiding duplication of same logic in multiple places.
Tests that could have been written as pure unit functions and benefit heavily from repetition of same setup are added as go-style unit tests only in separate files, keeping in mind the increasing size of nodereadinessrule_controller_test.go file.
The original issue, requests for an error count too. However during active development it was observed that errors appear purely from the network failure, RBAC or other kind of infra platform failures while applying/removing taints etc and not anywhere in the process of evaluation of nodes against the rules. That forced us to rely on nodeFailures of the status field. However, technically speaking nodeFailures in the worst case scenario of cluster wide failure can also lead to high memory usage pushing beyond 1.5MiB limit, and also the fact that it can trigger a rule write on each node event, makes it not so suitable field to retain in the long run just like nodeEvaluation. There were some other considerations around possible successor. However the final decision was to exclude error or failure count from initial RuleEvaluationSummary, because first of all the main purpose and name justifies that (because error is actually not associated with evaluation process directly) and to considering the fact that removing an existing field is harder than adding a new one (to not introduce tech debt now by using nodeFailure + to keep choices open for v1alpha2).
Related Issue
<!--
Automatically closes linked issue when PR is merged.
Usage:
Fixes #<issue number>, orFixes (paste link of issue).or
None
-->
Fixes #483
Type of Change
<!--
Add one of the following kinds:
/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind design
Optionally add one or more of the following kinds if applicable:
/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->
/kind feature
/kind api-change
Testing
<!-- How was this tested? -->
Tested with KWOK running the local build.
<img width="1091" height="352" alt="Screenshot 2026-11-14 at 2 54 31 AM" src="https://github.com/user-attachments/assets/aae15414-fb4b-467b-b23f-20aa53433ad9" />
<img width="507" height="325" alt="Screenshot 2026-11-14 at 2 56 30 AM" src="https://github.com/user-attachments/assets/23ebf6ae-d458-4362-9cb3-0ae64ef3a329" />
Checklist
make testpassesmake lintpassesDoes this PR introduce a user-facing change?
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
1. Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
2. Add 'Doc #(issue)' after the block if there is a follow up
For more information on release notes see: https://git.k8s.io/community/contributors/guide/release-notes.md
-->
``
release-note
``Add RuleEvaluationSummary to NodeReadinessStatus, presenting Targeted, Satisfied, and Unsatisfied node count against a Rule.
Generative AI Usage Disclosure
<!--
If you used AI tools in preparing this PR, please disclose and how they were used.
Using AI tools to help write your PR is acceptable, but as the author, you are responsible for understanding every change in your contribution.
Please write the PR description in your words. Do not submit AI-generated summary and analysis and do not leave the first review of AI generated changes to the reviewers, please verify the changes (code review, local testing, etc.) before submitting your PR.
For more details please review guidelines on responsible Generative AI usage:
https://www.linuxfoundation.org/legal/generative-aihttps://www.kubernetes.dev/docs/guide/pull-requests/#ai-guidance
-->
<!-- Describe what the AI helped with (e.g., code generation, refactoring, documentation, tests) and which parts of the PR were affected -->
AI was used to fetch references from upstream projects and other kind of information combined with reference quotation for me to review and understand. Also leveraged it for idea exploration including design options, and bootstrapping of code wherever applicable. Also used for test environment setup with Kwok and more.