← Back to Pull requests

✨ feat: introduce NodeReadinessEvaluation (NRE) CRD and controller #345

Open
Karthik-K-N opened this pull request with 2058 lines diff across 17 files
View on GitHub
Karthik-K-N Karthik-K-N commented on Aug 04, 2026 08:43 UTC
Author

<!-- Thanks for sending a pull request! Here are some tips for you:

  • If this is your first time, please read our contributor guidelines: https://git.k8s.io/community/contributors/guide#your-first-contribution and developer guide https://git.k8s.io/community/contributors/devel/development.md#development-guide

  • If you want faster PR reviews, read how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews

  • If the PR is unfinished, see how to mark it: https://git.k8s.io/community/contributors/guide/pull-requests.md#marking-unfinished-pull-requests

  • -->

    Description


    <!-- Brief description of changes -->

    Introduces the NodeReadinessEvaluation (NRE) custom resource and its dedicated reconciler. NRE provides a per-node, read-only mirror of the evaluated state of every applicable NodeReadinessRule, giving operators a single object to kubectl get nre <node-name> to see the full readiness picture of any node without having to cross-reference multiple rule statuses.

    Discussion document: https://docs.google.com/document/d/1DOP1G6i__nQN8qbhlSvdswkUquMeSKQY4LU554AbcgM/edit?usp=sharing

    Feature Flag

    The controller is opt-in via: --enable-node-readiness-evaluation

    Related Issue


    <!--
    *Automatically closes linked issue when PR is merged.
    Usage: Fixes #<issue number>, or Fixes (paste link of issue).

    Fixes #

    or

    None
    -->

    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
    -->

    Testing


    <!-- How was this tested? -->

    Checklist


  • make test passes

  • make lint passes
  • Does 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

    ``
    Doc #(issue)

    Diff: 2058 lines (+2002 / -56) across 17 files Reviewer: ajaysundark Review duration: 88010m
    All Vouch review confidence checks passed
    Residual risk 0.07 = Change Risk (0.79) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.79 · 2058 lines diff across 17 files
    0.79
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.94 · 5 substantive comment(s)
    0.94
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    90%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.400
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    40 items
    netlify[bot] netlify[bot] commented on Aug 04, 2026 08:44 UTC
    Bot

    <span aria-hidden="true">✅</span> Deploy Preview for node-readiness-controller canceled.

    | Name | Link |
    |:-:|------------------------|
    |<span aria-hidden="true">🔨</span> Latest commit | 99a1ca23c4e99ec285a73499aa0ffaabef6799b6 |
    |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/node-readiness-controller/deploys/6aa8e8bef2c5a70008102cc1 |

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Aug 04, 2026 08:44 UTC
    Bot

    [APPROVALNOTIFIER] This PR is NOT APPROVED

    This pull-request has been approved by: <a href="https://github.com/kubernetes-sigs/node-readiness-controller/pull/345#" title="Author self-approved">Karthik-K-N</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:

  • OWNERS
  • 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"]} -->

    ajaysundark ajaysundark commented on code on Aug 09, 2026 06:58 UTC
    Code Review
    internal/controller/nodereadinessevaluation_controller.go:1
    @@ -0,0 +1,395 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package controller
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	corev1 "k8s.io/api/core/v1"
    +	apierrors "k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/runtime"
    +	"k8s.io/apimachinery/pkg/types"
    +	ctrl "sigs.k8s.io/controller-runtime"
    +	"sigs.k8s.io/controller-runtime/pkg/builder"
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
    +	"sigs.k8s.io/controller-runtime/pkg/event"
    +	"sigs.k8s.io/controller-runtime/pkg/handler"
    +	"sigs.k8s.io/controller-runtime/pkg/predicate"
    +	"sigs.k8s.io/controller-runtime/pkg/reconcile"
    +
    +	readinessv1alpha1 "sigs.k8s.io/node-readiness-controller/api/v1alpha1"
    +)
    +
    +// NodeReadinessEvaluationReconciler is an independent reconciler that maintains
    +// one NodeReadinessEvaluation object per Node. It watches Nodes and
    +// NodeReadinessRules and re-evaluates the full rule set for the affected node
    +// on every relevant change. It shares the rule cache owned by
    +// RuleReadinessController but never writes to Node taints or NRR status —
    +// those remain the sole responsibility of NodeReconciler / RuleReconciler.
    +type NodeReadinessEvaluationReconciler struct {
    +	client.Client
    +	Scheme     *runtime.Scheme
    +	Controller *RuleReadinessController
    +}
    +
    +// SetupWithManager wires the reconciler to watch:
    +//   - Node objects (conditions, taints, labels)
    +//   - NodeReadinessRule objects (enqueues all nodes matching the changed rule)
    +func (r *NodeReadinessEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error {
    +	return ctrl.NewControllerManagedBy(mgr).

    @Karthik-K-N IIUC, this would trigger two parallel reconciliations for node updates (NodeReconciler and NREReconciler) and one is handling the output of the other. I wonder if a separate controller for NRE is a better fitting pattern for this or should be bridged into NodeReconciler's watch?

    Karthik-K-N Karthik-K-N commented on code on Aug 10, 2026 06:03 UTC
    Code Review
    internal/controller/nodereadinessevaluation_controller.go:1
    @@ -0,0 +1,395 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package controller
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	corev1 "k8s.io/api/core/v1"
    +	apierrors "k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/runtime"
    +	"k8s.io/apimachinery/pkg/types"
    +	ctrl "sigs.k8s.io/controller-runtime"
    +	"sigs.k8s.io/controller-runtime/pkg/builder"
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
    +	"sigs.k8s.io/controller-runtime/pkg/event"
    +	"sigs.k8s.io/controller-runtime/pkg/handler"
    +	"sigs.k8s.io/controller-runtime/pkg/predicate"
    +	"sigs.k8s.io/controller-runtime/pkg/reconcile"
    +
    +	readinessv1alpha1 "sigs.k8s.io/node-readiness-controller/api/v1alpha1"
    +)
    +
    +// NodeReadinessEvaluationReconciler is an independent reconciler that maintains
    +// one NodeReadinessEvaluation object per Node. It watches Nodes and
    +// NodeReadinessRules and re-evaluates the full rule set for the affected node
    +// on every relevant change. It shares the rule cache owned by
    +// RuleReadinessController but never writes to Node taints or NRR status —
    +// those remain the sole responsibility of NodeReconciler / RuleReconciler.
    +type NodeReadinessEvaluationReconciler struct {
    +	client.Client
    +	Scheme     *runtime.Scheme
    +	Controller *RuleReadinessController
    +}
    +
    +// SetupWithManager wires the reconciler to watch:
    +//   - Node objects (conditions, taints, labels)
    +//   - NodeReadinessRule objects (enqueues all nodes matching the changed rule)
    +func (r *NodeReadinessEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error {
    +	return ctrl.NewControllerManagedBy(mgr).

    yes I thought about that and I missed to point out why I chose this way, here are my thoughts
    1. Initially tried combining both into the NodeReconciler, but then when I checked with best practices of writing controller, if we do so we will be merging two different operations into one, Node controller adding/removing taints,NRE just storing the result, One failure should not cause requeue for other and I think NodeReconcile should be as quick as possible as it affects the workloads.
    2. Followed the existing pattern of having separate controllers like NRR, Node and NRE
    3. Even if there is race and NRE reconciles first and later the Node, Since the NRE also watches for condition, taint and label, if something updated by the Node Rec then eventually it triggers the NRE. We will be eventually consistent.

    These are the thoughts and I lean towards keeping them separate, but let me know what do you think.

    DsThakurRawat DsThakurRawat commented on Aug 11, 2026 13:06 UTC
    Contributor

    i tested this branch and found two behaviours worth knowing about, plus one interaction with #315. all three are reproduced with runnable tests, happy to share them.

    first, a rule-creation window that never heals. the NRE fan-out fires on the rule Create event (GenerationChangedPredicate only filters updates), but the shared ruleCache is only populated on the rule controller's second reconcile pass, because the first one adds the finalizer and returns RequeueAfter one second. so the NRE reconciles for every matching node run against a cache that cannot contain the new rule yet. for rules whose evaluation then changes a node, the taint write re-triggers the node watch and everything heals. but for a rule whose conditions are already satisfied everywhere, nothing mutates any node, the rule's status patch doesn't bump generation, heartbeats don't pass the node predicate (it compares only condition type to status), and informer resyncs are filtered as no-ops. the NRE just permanently misses the rule until some unrelated node change. deletion is fine, reconcileDelete empties the cache before dropping the finalizer. i think this is the concrete version of the question ajaysundark raised above: the reconciler's correctness depends on another controller's queue having run first. listing rules from the informer inside Reconcile instead of reading the private cache would remove the ordering dependency entirely.

    second, this branch merges cleanly with #315, and the two disagree once combined. evaluateRuleForNode there honours conditionPolicy anyOf, while buildRuleEvaluation here ANDs every condition unconditionally. an anyOf rule with one of two conditions satisfied ends up enforced as satisfied (no taint) while the NRE for the same node reports it Unmatched. a shared evaluation helper honouring GetConditionPolicy() in both paths would keep them from drifting.

    small one: nothing currently produces RuleStatusError, so the Errors count, State Pending, and the Evaluated False condition are unreachable in this iteration. fine if that's intentional groundwork, might deserve a TODO.

    ajaysundark ajaysundark commented on Aug 21, 2026 03:47 UTC
    Contributor

    @Karthik-K-N is this ready for review?

    Karthik-K-N Karthik-K-N commented on Aug 21, 2026 04:36 UTC
    Author

    @Karthik-K-N is this ready for review?

    yes , its ready for review

    DsThakurRawat DsThakurRawat commented on Aug 21, 2026 16:13 UTC
    Contributor

    The rule-creation window I flagged here on Aug 11 has a second victim now, and this one is worse because it's the reporting surface. Walked the sequence on your head 7c0ecc42: a rule Create passes GenerationChangedPredicate into this controller too, ruleToNodeRequests enqueues the matching nodes immediately, but the NRE reconciler reads getApplicableRulesForNode, which serves only the private ruleCache, and the cache isn't populated until the rule controller's second reconcile, because the first one just adds the finalizer and returns RequeueAfter one second (nodereadinessrule_controller.go:118-125, cache write at :139). So for a rule whose conditions are already satisfied on every matching node and whose taint is absent everywhere, the NRE usually reconciles against the empty cache and writes state: Ready with zero rule entries. Nothing corrects it after that: evaluation mutates no node, so no node event fires, and resync updates die on your equality predicates in the For(). Until something else happens to touch that node, the NRE keeps telling any reader (#327's history story, dashboards) that no rule applies to it while one actively does.

    The Aug 11 fix suggestion covers both consumers, and it got cheaper to justify: have this controller read rules through the informer instead of the private cache, and the ordering dependency disappears rather than getting patched around.

    Separately, I reproduced prow's lint failure locally so it can be named precisely: gocritic ifElseChain on the four-way taint transition at nodereadinessevaluation_controller.go:290, and unparam's unused ctx in the test's sharedSetup at :91. Both trivial.

    What I checked that holds: rule deletions do reach this controller (in controller-runtime v0.24.1 a nil DeleteFunc defaults to passing, so GenerationChangedPredicate only filters updates), and your D1 shows the prune works once a reconcile runs; the CEL immutability on nodeSelector makes mapping by selector safe across rule updates; node deletion is covered by the ownerReference; and the single-writer separation is real, this reconciler writes nothing but its own status. One RBAC nit: the marker asks delete on nodereadinessevaluations but nothing in the code ever calls it, GC does that work.

    ajaysundark ajaysundark commented on code on Aug 24, 2026 07:35 UTC
    Code Review
    internal/controller/nodereadinessevaluation_controller.go:1
    @@ -0,0 +1,395 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package controller
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	corev1 "k8s.io/api/core/v1"
    +	apierrors "k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/runtime"
    +	"k8s.io/apimachinery/pkg/types"
    +	ctrl "sigs.k8s.io/controller-runtime"
    +	"sigs.k8s.io/controller-runtime/pkg/builder"
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
    +	"sigs.k8s.io/controller-runtime/pkg/event"
    +	"sigs.k8s.io/controller-runtime/pkg/handler"
    +	"sigs.k8s.io/controller-runtime/pkg/predicate"
    +	"sigs.k8s.io/controller-runtime/pkg/reconcile"
    +
    +	readinessv1alpha1 "sigs.k8s.io/node-readiness-controller/api/v1alpha1"
    +)
    +
    +// NodeReadinessEvaluationReconciler is an independent reconciler that maintains
    +// one NodeReadinessEvaluation object per Node. It watches Nodes and
    +// NodeReadinessRules and re-evaluates the full rule set for the affected node
    +// on every relevant change. It shares the rule cache owned by
    +// RuleReadinessController but never writes to Node taints or NRR status —
    +// those remain the sole responsibility of NodeReconciler / RuleReconciler.
    +type NodeReadinessEvaluationReconciler struct {
    +	client.Client
    +	Scheme     *runtime.Scheme
    +	Controller *RuleReadinessController
    +}
    +
    +// SetupWithManager wires the reconciler to watch:
    +//   - Node objects (conditions, taints, labels)
    +//   - NodeReadinessRule objects (enqueues all nodes matching the changed rule)
    +func (r *NodeReadinessEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error {
    +	return ctrl.NewControllerManagedBy(mgr).

    My concern with another reconciler is that we are reintroducing a shared (Node) state again between two controllers. looking at buildRuleEvaluation it is very similar to evaluateRuleForNode. reevaluating the node status between two controllers with caches seem like a bad idea (and that seems like repeating what we did and trying to change with rule.status). :/

    I saw https://github.com/kubernetes-sigs/node-readiness-controller/pull/343 emitting individual nodeStatusDelta in rule-reconciliation, which could make adding NRE even cheaper than before. Happy to discuss more / hear your thoughts further on this.

    ajaysundark ajaysundark commented on code on Aug 24, 2026 07:39 UTC
    Code Review
    internal/controller/nodereadinessevaluation_controller.go:1
    @@ -0,0 +1,395 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package controller
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	corev1 "k8s.io/api/core/v1"
    +	apierrors "k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/runtime"
    +	"k8s.io/apimachinery/pkg/types"
    +	ctrl "sigs.k8s.io/controller-runtime"
    +	"sigs.k8s.io/controller-runtime/pkg/builder"
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
    +	"sigs.k8s.io/controller-runtime/pkg/event"
    +	"sigs.k8s.io/controller-runtime/pkg/handler"
    +	"sigs.k8s.io/controller-runtime/pkg/predicate"
    +	"sigs.k8s.io/controller-runtime/pkg/reconcile"
    +
    +	readinessv1alpha1 "sigs.k8s.io/node-readiness-controller/api/v1alpha1"
    +)
    +
    +// NodeReadinessEvaluationReconciler is an independent reconciler that maintains
    +// one NodeReadinessEvaluation object per Node. It watches Nodes and
    +// NodeReadinessRules and re-evaluates the full rule set for the affected node
    +// on every relevant change. It shares the rule cache owned by
    +// RuleReadinessController but never writes to Node taints or NRR status —
    +// those remain the sole responsibility of NodeReconciler / RuleReconciler.
    +type NodeReadinessEvaluationReconciler struct {
    +	client.Client
    +	Scheme     *runtime.Scheme
    +	Controller *RuleReadinessController
    +}
    +
    +// SetupWithManager wires the reconciler to watch:
    +//   - Node objects (conditions, taints, labels)
    +//   - NodeReadinessRule objects (enqueues all nodes matching the changed rule)
    +func (r *NodeReadinessEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error {
    +	return ctrl.NewControllerManagedBy(mgr).
    +		Named("nodereadinessevaluation").
    +		// Primary watch: a node change triggers reconcile for that node's NRE.
    +		For(&corev1.Node{}, builder.WithPredicates(predicate.Funcs{
    +			CreateFunc: func(e event.CreateEvent) bool { return true },
    +			UpdateFunc: func(e event.UpdateEvent) bool {
    +				oldNode := e.ObjectOld.(*corev1.Node)
    +				newNode := e.ObjectNew.(*corev1.Node)
    +				return !conditionsEqual(oldNode.Status.Conditions, newNode.Status.Conditions) ||
    +					!taintsEqual(oldNode.Spec.Taints, newNode.Spec.Taints) ||
    +					!labelsEqual(oldNode.Labels, newNode.Labels)
    +			},
    +			DeleteFunc:  func(e event.DeleteEvent) bool { return false }, // GC handles deletion via ownerRef
    +			GenericFunc: func(e event.GenericEvent) bool { return false },
    +		})).
    +		// Secondary watch: a rule change re-evaluates every node in the cluster
    +		// that could be affected. We map the rule event to a list of node requests.
    +		Watches(
    +			&readinessv1alpha1.NodeReadinessRule{},
    +			handler.EnqueueRequestsFromMapFunc(r.ruleToNodeRequests),
    +			builder.WithPredicates(predicate.GenerationChangedPredicate{}),
    +		).
    +		Complete(r)
    +}
    +
    +// ruleToNodeRequests maps a NodeReadinessRule event to reconcile requests for
    +// only the Nodes that match the rule's nodeSelector. Filtering here avoids
    +// enqueueing the full cluster on every rule change — on a 5k-node cluster a
    +// rule targeting 200 nodes produces 200 requests, not 5,000.
    +//
    +// nodeSelector is immutable enforeced via CEL validateion on the spec, so a changing
    +// selector can never silently leave stale NRE entries behind.
    +func (r *NodeReadinessEvaluationReconciler) ruleToNodeRequests(ctx context.Context, obj client.Object) []reconcile.Request {
    +	log := ctrl.LoggerFrom(ctx)
    +
    +	rule, ok := obj.(*readinessv1alpha1.NodeReadinessRule)
    +	if !ok {
    +		return nil
    +	}
    +
    +	selector, err := metav1.LabelSelectorAsSelector(&rule.Spec.NodeSelector)
    +	if err != nil {
    +		// Invalid selector — the rule reconciler will surface this as an error;
    +		// nothing to enqueue here.
    +		log.Error(err, "invalid nodeSelector on rule, skipping NRE fan-out", "rule", rule.Name)
    +		return nil
    +	}
    +
    +	nodeList := &corev1.NodeList{}
    +	if err := r.List(ctx, nodeList, client.MatchingLabelsSelector{Selector: selector}); err != nil {
    +		log.Error(err, "failed to list matching nodes for NRE rule mapping", "rule", rule.Name)
    +		return nil
    +	}
    +
    +	requests := make([]reconcile.Request, len(nodeList.Items))
    +	for i, node := range nodeList.Items {
    +		requests[i] = reconcile.Request{
    +			NamespacedName: types.NamespacedName{Name: node.Name},
    +		}
    +	}
    +
    +	log.V(4).Info("Enqueuing NRE reconciles for rule change",
    +		"rule", rule.Name, "matchingNodes", len(requests))
    +	return requests
    +}
    +
    +// +kubebuilder:rbac:groups=readiness.node.x-k8s.io,resources=nodereadinessevaluations,verbs=get;list;watch;create;update;patch;delete
    +// +kubebuilder:rbac:groups=readiness.node.x-k8s.io,resources=nodereadinessevaluations/status,verbs=get;update;patch
    +
    +// Reconcile evaluates all applicable rules for the given node and writes the
    +// result into the corresponding NodeReadinessEvaluation object.
    +func (r *NodeReadinessEvaluationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
    +	log := ctrl.LoggerFrom(ctx)
    +	log.V(4).Info("Reconciling NodeReadinessEvaluation", "node", req.Name)
    +
    +	// Fetch the Node.
    +	node := &corev1.Node{}
    +	if err := r.Get(ctx, req.NamespacedName, node); err != nil {
    +		return ctrl.Result{}, client.IgnoreNotFound(err)
    +	}
    +
    +	// Fetch or create the NRE object.
    +	nre, err := r.ensureNRE(ctx, node)
    +	if err != nil {
    +		return ctrl.Result{}, err
    +	}
    +
    +	// Evaluate all applicable rules from the shared cache.
    +	applicableRules := r.Controller.getApplicableRulesForNode(ctx, node)
    +	log.V(4).Info("Evaluating rules for NRE", "node", node.Name, "ruleCount", len(applicableRules))
    +
    +	// Snapshot the previous rules slice for timestamp carry-forward BEFORE
    +	// clearing it. buildRuleEvaluation reads from this snapshot via nre.Status.Rules,
    +	// so it must not be cleared until after all evaluations are complete.
    +	prevRules := make([]readinessv1alpha1.RuleEvaluation, len(nre.Status.Rules))
    +	copy(prevRules, nre.Status.Rules)
    +
    +	patch := client.MergeFrom(nre.DeepCopy())
    +
    +	// Rebuild the full rules slice from scratch on every reconcile.
    +	// listType=atomic means the controller owns the whole slice.
    +	newRules := make([]readinessv1alpha1.RuleEvaluation, 0, len(applicableRules))
    +	for _, rule := range applicableRules {
    +		if !rule.DeletionTimestamp.IsZero() || rule.Spec.DryRun {
    +			continue
    +		}
    +		ruleEval := r.buildRuleEvaluation(ctx, node, rule, prevRules)
    +		newRules = append(newRules, ruleEval)
    +	}
    +	nre.Status.Rules = newRules
    +
    +	recomputeNREStatus(&nre.Status)
    +
    +	if err := r.Status().Patch(ctx, nre, patch); err != nil {
    +		return ctrl.Result{}, fmt.Errorf("failed to patch NRE status %s: %w", node.Name, err)
    +	}
    +
    +	log.V(4).Info("Reconciled NRE", "node", node.Name, "rules", len(nre.Status.Rules), "state", nre.Status.State)
    +	return ctrl.Result{}, nil
    +}
    +
    +// ensureNRE fetches the NRE for the node, creating it (with ownerReference) if
    +// it does not exist yet. Returns the current object ready for status patching.
    +func (r *NodeReadinessEvaluationReconciler) ensureNRE(ctx context.Context, node *corev1.Node) (*readinessv1alpha1.NodeReadinessEvaluation, error) {
    +	nre := &readinessv1alpha1.NodeReadinessEvaluation{}
    +	err := r.Get(ctx, client.ObjectKey{Name: node.Name}, nre)
    +
    +	switch {
    +	case apierrors.IsNotFound(err):
    +		nre = &readinessv1alpha1.NodeReadinessEvaluation{
    +			ObjectMeta: metav1.ObjectMeta{
    +				Name: node.Name,
    +			},
    +			Spec: readinessv1alpha1.NodeReadinessEvaluationSpec{
    +				NodeName: node.Name,
    +			},
    +		}
    +		if ownerErr := controllerutil.SetOwnerReference(node, nre, r.Scheme); ownerErr != nil {
    +			return nil, fmt.Errorf("failed to set owner reference on NRE %s: %w", node.Name, ownerErr)
    +		}
    +		if createErr := r.Create(ctx, nre); createErr != nil {
    +			if !apierrors.IsAlreadyExists(createErr) {
    +				return nil, fmt.Errorf("failed to create NRE %s: %w", node.Name, createErr)
    +			}
    +			// A concurrent reconcile won the race — re-fetch.
    +			if getErr := r.Get(ctx, client.ObjectKey{Name: node.Name}, nre); getErr != nil {
    +				return nil, fmt.Errorf("failed to get NRE %s after AlreadyExists: %w", node.Name, getErr)
    +			}
    +		}
    +		ctrl.LoggerFrom(ctx).V(4).Info("Created NodeReadinessEvaluation", "nre", node.Name)
    +
    +	case err != nil:
    +		return nil, fmt.Errorf("failed to get NRE %s: %w", node.Name, err)
    +	}
    +
    +	return nre, nil
    +}
    +
    +// buildRuleEvaluation evaluates a single rule against the node and constructs
    +// the RuleEvaluation entry, preserving SLI timestamps from prevRules (the
    +// snapshot of the previous status.rules slice taken before the rebuild started).
    +func (r *NodeReadinessEvaluationReconciler) buildRuleEvaluation(
    +	ctx context.Context,
    +	node *corev1.Node,
    +	rule *readinessv1alpha1.NodeReadinessRule,
    +	prevRules []readinessv1alpha1.RuleEvaluation,
    +) readinessv1alpha1.RuleEvaluation {
    +	log := ctrl.LoggerFrom(ctx)
    +	now := metav1.Now()
    +
    +	// Evaluate all conditions.
    +	allConditionsSatisfied := true
    +	conditionResults := make([]readinessv1alpha1.ConditionEvaluationResult, 0, len(rule.Spec.Conditions))
    +	for _, condReq := range rule.Spec.Conditions {
    +		effectiveStatus, conditionFound := r.Controller.getConditionStatus(node, condReq.Type, condReq.GetDefaultStatus())
    +		satisfied := effectiveStatus == condReq.RequiredStatus
    +		if !satisfied {
    +			allConditionsSatisfied = false
    +		}
    +		observedStatus := effectiveStatus
    +		if !conditionFound {
    +			observedStatus = corev1.ConditionUnknown
    +		}
    +		conditionResults = append(conditionResults, readinessv1alpha1.ConditionEvaluationResult{
    +			Type:           condReq.Type,
    +			CurrentStatus:  observedStatus,
    +			RequiredStatus: condReq.RequiredStatus,
    +			DefaultStatus:  condReq.GetDefaultStatus(),
    +		})
    +	}
    +
    +	ruleStatus := readinessv1alpha1.RuleStatusMatched
    +	if !allConditionsSatisfied {
    +		ruleStatus = readinessv1alpha1.RuleStatusUnmatched
    +	}
    +
    +	taintPresent := r.Controller.hasTaintBySpec(node, rule.Spec.Taint)
    +	taintStatus := readinessv1alpha1.TaintStatusAbsent
    +	if taintPresent {
    +		taintStatus = readinessv1alpha1.TaintStatusPresent
    +	}
    +
    +	log.V(4).Info("Rule evaluation for NRE",
    +		"node", node.Name, "rule", rule.Name,
    +		"ruleStatus", ruleStatus, "taintStatus", taintStatus)
    +
    +	// Carry forward timestamps from the previous evaluation entry if present.
    +	prev := findPreviousRuleEvaluation(prevRules, rule.Name)
    +
    +	eval := readinessv1alpha1.RuleEvaluation{
    +		RuleRef: readinessv1alpha1.RuleRef{
    +			Name: rule.Name,
    +			UID:  rule.GetUID(),
    +		},
    +		RuleStatus:          ruleStatus,
    +		TaintStatus:         taintStatus,
    +		ReadinessConditions: conditionResults,
    +		LastEvaluationTime:  now,
    +	}
    +
    +	// FirstEvaluatedAt: set once, carried forward on subsequent evaluations.
    +	if prev != nil && prev.RuleRef.UID == rule.GetUID() {
    +		eval.FirstEvaluatedAt = prev.FirstEvaluatedAt
    +	} else {
    +		// No previous entry, or the rule was deleted and recreated (UID changed).
    +		eval.FirstEvaluatedAt = &now
    +	}
    +
    +	// Taint timestamp transitions — four cases covering every state combination.
    +	// TaintRemovedAt is carried forward once set so the SLI is always queryable,
    +	// not just on the exact reconcile cycle where removal happened.
    +	if prev != nil && prev.RuleRef.UID == rule.GetUID() {
    +		prevTaintPresent := prev.TaintStatus == readinessv1alpha1.TaintStatusPresent
    +		if taintPresent && prevTaintPresent {
    +			// State unchanged: taint still active — carry forward all timestamps.
    +			eval.TaintObservedAt = prev.TaintObservedAt
    +			eval.TaintAddedAt = prev.TaintAddedAt
    +		} else if taintPresent && !prevTaintPresent {
    +			// Transition: Absent → Present — NRC just added the taint.
    +			eval.TaintObservedAt = &now
    +			eval.TaintAddedAt = &now
    +		} else if !taintPresent && prevTaintPresent {
    +			// Transition: Present → Absent — NRC just removed the taint.
    +			eval.TaintRemovedAt = &now
    +		} else {
    +			// State unchanged: taint still absent — carry forward historical removal time.
    +			eval.TaintRemovedAt = prev.TaintRemovedAt
    +		}
    +	} else if taintPresent {
    +		// First evaluation for this rule (or rule recreated) and taint is already
    +		// present — NRC is adopting a pre-existing taint.
    +		eval.TaintObservedAt = &now
    +		// TaintAddedAt stays nil — NRC did not add this taint.
    +	}
    +
    +	return eval
    +}
    +
    +// findPreviousRuleEvaluation returns the existing RuleEvaluation entry for the
    +// given rule name in the previous rules snapshot, or nil if not found.
    +func findPreviousRuleEvaluation(prevRules []readinessv1alpha1.RuleEvaluation, ruleName string) *readinessv1alpha1.RuleEvaluation {
    +	for i := range prevRules {
    +		if prevRules[i].RuleRef.Name == ruleName {
    +			return &prevRules[i]
    +		}
    +	}
    +	return nil
    +}
    +
    +// recomputeNREStatus derives status.State, status.Summary, and status.Conditions
    +// from the current rules slice. Called after every full rebuild so all top-level
    +// fields stay consistent.
    +func recomputeNREStatus(status *readinessv1alpha1.NodeReadinessEvaluationStatus) {
    +	var matched, unmatched, activeTaints, errors int32
    +
    +	for _, r := range status.Rules {
    +		switch r.RuleStatus {
    +		case readinessv1alpha1.RuleStatusMatched:

    The Matched / Unmatched rules on status is bit unclear to me. Sorry I missed to get this at the doc, will look into it again.

    ajaysundark ajaysundark commented on code on Aug 24, 2026 07:45 UTC
    Code Review
    internal/controller/nodereadinessevaluation_controller.go:1
    @@ -0,0 +1,395 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package controller
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	corev1 "k8s.io/api/core/v1"
    +	apierrors "k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/runtime"
    +	"k8s.io/apimachinery/pkg/types"
    +	ctrl "sigs.k8s.io/controller-runtime"
    +	"sigs.k8s.io/controller-runtime/pkg/builder"
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
    +	"sigs.k8s.io/controller-runtime/pkg/event"
    +	"sigs.k8s.io/controller-runtime/pkg/handler"
    +	"sigs.k8s.io/controller-runtime/pkg/predicate"
    +	"sigs.k8s.io/controller-runtime/pkg/reconcile"
    +
    +	readinessv1alpha1 "sigs.k8s.io/node-readiness-controller/api/v1alpha1"
    +)
    +
    +// NodeReadinessEvaluationReconciler is an independent reconciler that maintains
    +// one NodeReadinessEvaluation object per Node. It watches Nodes and
    +// NodeReadinessRules and re-evaluates the full rule set for the affected node
    +// on every relevant change. It shares the rule cache owned by
    +// RuleReadinessController but never writes to Node taints or NRR status —
    +// those remain the sole responsibility of NodeReconciler / RuleReconciler.
    +type NodeReadinessEvaluationReconciler struct {
    +	client.Client
    +	Scheme     *runtime.Scheme
    +	Controller *RuleReadinessController
    +}
    +
    +// SetupWithManager wires the reconciler to watch:
    +//   - Node objects (conditions, taints, labels)
    +//   - NodeReadinessRule objects (enqueues all nodes matching the changed rule)
    +func (r *NodeReadinessEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error {
    +	return ctrl.NewControllerManagedBy(mgr).
    +		Named("nodereadinessevaluation").
    +		// Primary watch: a node change triggers reconcile for that node's NRE.
    +		For(&corev1.Node{}, builder.WithPredicates(predicate.Funcs{
    +			CreateFunc: func(e event.CreateEvent) bool { return true },
    +			UpdateFunc: func(e event.UpdateEvent) bool {
    +				oldNode := e.ObjectOld.(*corev1.Node)
    +				newNode := e.ObjectNew.(*corev1.Node)
    +				return !conditionsEqual(oldNode.Status.Conditions, newNode.Status.Conditions) ||
    +					!taintsEqual(oldNode.Spec.Taints, newNode.Spec.Taints) ||
    +					!labelsEqual(oldNode.Labels, newNode.Labels)
    +			},
    +			DeleteFunc:  func(e event.DeleteEvent) bool { return false }, // GC handles deletion via ownerRef
    +			GenericFunc: func(e event.GenericEvent) bool { return false },
    +		})).
    +		// Secondary watch: a rule change re-evaluates every node in the cluster
    +		// that could be affected. We map the rule event to a list of node requests.
    +		Watches(
    +			&readinessv1alpha1.NodeReadinessRule{},
    +			handler.EnqueueRequestsFromMapFunc(r.ruleToNodeRequests),
    +			builder.WithPredicates(predicate.GenerationChangedPredicate{}),
    +		).
    +		Complete(r)
    +}
    +
    +// ruleToNodeRequests maps a NodeReadinessRule event to reconcile requests for
    +// only the Nodes that match the rule's nodeSelector. Filtering here avoids
    +// enqueueing the full cluster on every rule change — on a 5k-node cluster a
    +// rule targeting 200 nodes produces 200 requests, not 5,000.
    +//
    +// nodeSelector is immutable enforeced via CEL validateion on the spec, so a changing
    +// selector can never silently leave stale NRE entries behind.
    +func (r *NodeReadinessEvaluationReconciler) ruleToNodeRequests(ctx context.Context, obj client.Object) []reconcile.Request {
    +	log := ctrl.LoggerFrom(ctx)
    +
    +	rule, ok := obj.(*readinessv1alpha1.NodeReadinessRule)
    +	if !ok {
    +		return nil
    +	}
    +
    +	selector, err := metav1.LabelSelectorAsSelector(&rule.Spec.NodeSelector)
    +	if err != nil {
    +		// Invalid selector — the rule reconciler will surface this as an error;
    +		// nothing to enqueue here.
    +		log.Error(err, "invalid nodeSelector on rule, skipping NRE fan-out", "rule", rule.Name)
    +		return nil
    +	}
    +
    +	nodeList := &corev1.NodeList{}
    +	if err := r.List(ctx, nodeList, client.MatchingLabelsSelector{Selector: selector}); err != nil {
    +		log.Error(err, "failed to list matching nodes for NRE rule mapping", "rule", rule.Name)
    +		return nil
    +	}
    +
    +	requests := make([]reconcile.Request, len(nodeList.Items))
    +	for i, node := range nodeList.Items {
    +		requests[i] = reconcile.Request{
    +			NamespacedName: types.NamespacedName{Name: node.Name},
    +		}
    +	}
    +
    +	log.V(4).Info("Enqueuing NRE reconciles for rule change",
    +		"rule", rule.Name, "matchingNodes", len(requests))
    +	return requests
    +}
    +
    +// +kubebuilder:rbac:groups=readiness.node.x-k8s.io,resources=nodereadinessevaluations,verbs=get;list;watch;create;update;patch;delete
    +// +kubebuilder:rbac:groups=readiness.node.x-k8s.io,resources=nodereadinessevaluations/status,verbs=get;update;patch
    +
    +// Reconcile evaluates all applicable rules for the given node and writes the
    +// result into the corresponding NodeReadinessEvaluation object.
    +func (r *NodeReadinessEvaluationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
    +	log := ctrl.LoggerFrom(ctx)
    +	log.V(4).Info("Reconciling NodeReadinessEvaluation", "node", req.Name)
    +
    +	// Fetch the Node.
    +	node := &corev1.Node{}
    +	if err := r.Get(ctx, req.NamespacedName, node); err != nil {
    +		return ctrl.Result{}, client.IgnoreNotFound(err)
    +	}
    +
    +	// Fetch or create the NRE object.
    +	nre, err := r.ensureNRE(ctx, node)
    +	if err != nil {
    +		return ctrl.Result{}, err
    +	}
    +
    +	// Evaluate all applicable rules from the shared cache.
    +	applicableRules := r.Controller.getApplicableRulesForNode(ctx, node)
    +	log.V(4).Info("Evaluating rules for NRE", "node", node.Name, "ruleCount", len(applicableRules))
    +
    +	// Snapshot the previous rules slice for timestamp carry-forward BEFORE
    +	// clearing it. buildRuleEvaluation reads from this snapshot via nre.Status.Rules,
    +	// so it must not be cleared until after all evaluations are complete.
    +	prevRules := make([]readinessv1alpha1.RuleEvaluation, len(nre.Status.Rules))
    +	copy(prevRules, nre.Status.Rules)
    +
    +	patch := client.MergeFrom(nre.DeepCopy())
    +
    +	// Rebuild the full rules slice from scratch on every reconcile.
    +	// listType=atomic means the controller owns the whole slice.
    +	newRules := make([]readinessv1alpha1.RuleEvaluation, 0, len(applicableRules))
    +	for _, rule := range applicableRules {
    +		if !rule.DeletionTimestamp.IsZero() || rule.Spec.DryRun {
    +			continue
    +		}
    +		ruleEval := r.buildRuleEvaluation(ctx, node, rule, prevRules)
    +		newRules = append(newRules, ruleEval)
    +	}
    +	nre.Status.Rules = newRules
    +
    +	recomputeNREStatus(&nre.Status)
    +
    +	if err := r.Status().Patch(ctx, nre, patch); err != nil {
    +		return ctrl.Result{}, fmt.Errorf("failed to patch NRE status %s: %w", node.Name, err)
    +	}
    +
    +	log.V(4).Info("Reconciled NRE", "node", node.Name, "rules", len(nre.Status.Rules), "state", nre.Status.State)
    +	return ctrl.Result{}, nil
    +}
    +
    +// ensureNRE fetches the NRE for the node, creating it (with ownerReference) if
    +// it does not exist yet. Returns the current object ready for status patching.
    +func (r *NodeReadinessEvaluationReconciler) ensureNRE(ctx context.Context, node *corev1.Node) (*readinessv1alpha1.NodeReadinessEvaluation, error) {
    +	nre := &readinessv1alpha1.NodeReadinessEvaluation{}
    +	err := r.Get(ctx, client.ObjectKey{Name: node.Name}, nre)
    +
    +	switch {
    +	case apierrors.IsNotFound(err):
    +		nre = &readinessv1alpha1.NodeReadinessEvaluation{
    +			ObjectMeta: metav1.ObjectMeta{
    +				Name: node.Name,
    +			},
    +			Spec: readinessv1alpha1.NodeReadinessEvaluationSpec{
    +				NodeName: node.Name,
    +			},
    +		}
    +		if ownerErr := controllerutil.SetOwnerReference(node, nre, r.Scheme); ownerErr != nil {
    +			return nil, fmt.Errorf("failed to set owner reference on NRE %s: %w", node.Name, ownerErr)
    +		}
    +		if createErr := r.Create(ctx, nre); createErr != nil {
    +			if !apierrors.IsAlreadyExists(createErr) {
    +				return nil, fmt.Errorf("failed to create NRE %s: %w", node.Name, createErr)
    +			}
    +			// A concurrent reconcile won the race — re-fetch.
    +			if getErr := r.Get(ctx, client.ObjectKey{Name: node.Name}, nre); getErr != nil {
    +				return nil, fmt.Errorf("failed to get NRE %s after AlreadyExists: %w", node.Name, getErr)
    +			}
    +		}
    +		ctrl.LoggerFrom(ctx).V(4).Info("Created NodeReadinessEvaluation", "nre", node.Name)
    +
    +	case err != nil:
    +		return nil, fmt.Errorf("failed to get NRE %s: %w", node.Name, err)
    +	}
    +
    +	return nre, nil
    +}
    +
    +// buildRuleEvaluation evaluates a single rule against the node and constructs
    +// the RuleEvaluation entry, preserving SLI timestamps from prevRules (the
    +// snapshot of the previous status.rules slice taken before the rebuild started).
    +func (r *NodeReadinessEvaluationReconciler) buildRuleEvaluation(
    +	ctx context.Context,
    +	node *corev1.Node,
    +	rule *readinessv1alpha1.NodeReadinessRule,
    +	prevRules []readinessv1alpha1.RuleEvaluation,
    +) readinessv1alpha1.RuleEvaluation {
    +	log := ctrl.LoggerFrom(ctx)
    +	now := metav1.Now()
    +
    +	// Evaluate all conditions.
    +	allConditionsSatisfied := true
    +	conditionResults := make([]readinessv1alpha1.ConditionEvaluationResult, 0, len(rule.Spec.Conditions))
    +	for _, condReq := range rule.Spec.Conditions {
    +		effectiveStatus, conditionFound := r.Controller.getConditionStatus(node, condReq.Type, condReq.GetDefaultStatus())
    +		satisfied := effectiveStatus == condReq.RequiredStatus
    +		if !satisfied {
    +			allConditionsSatisfied = false
    +		}
    +		observedStatus := effectiveStatus
    +		if !conditionFound {
    +			observedStatus = corev1.ConditionUnknown
    +		}
    +		conditionResults = append(conditionResults, readinessv1alpha1.ConditionEvaluationResult{
    +			Type:           condReq.Type,
    +			CurrentStatus:  observedStatus,
    +			RequiredStatus: condReq.RequiredStatus,
    +			DefaultStatus:  condReq.GetDefaultStatus(),
    +		})
    +	}
    +
    +	ruleStatus := readinessv1alpha1.RuleStatusMatched
    +	if !allConditionsSatisfied {
    +		ruleStatus = readinessv1alpha1.RuleStatusUnmatched
    +	}
    +
    +	taintPresent := r.Controller.hasTaintBySpec(node, rule.Spec.Taint)
    +	taintStatus := readinessv1alpha1.TaintStatusAbsent
    +	if taintPresent {
    +		taintStatus = readinessv1alpha1.TaintStatusPresent
    +	}
    +
    +	log.V(4).Info("Rule evaluation for NRE",
    +		"node", node.Name, "rule", rule.Name,
    +		"ruleStatus", ruleStatus, "taintStatus", taintStatus)
    +
    +	// Carry forward timestamps from the previous evaluation entry if present.
    +	prev := findPreviousRuleEvaluation(prevRules, rule.Name)
    +
    +	eval := readinessv1alpha1.RuleEvaluation{
    +		RuleRef: readinessv1alpha1.RuleRef{
    +			Name: rule.Name,
    +			UID:  rule.GetUID(),
    +		},
    +		RuleStatus:          ruleStatus,
    +		TaintStatus:         taintStatus,
    +		ReadinessConditions: conditionResults,
    +		LastEvaluationTime:  now,
    +	}
    +
    +	// FirstEvaluatedAt: set once, carried forward on subsequent evaluations.
    +	if prev != nil && prev.RuleRef.UID == rule.GetUID() {
    +		eval.FirstEvaluatedAt = prev.FirstEvaluatedAt
    +	} else {
    +		// No previous entry, or the rule was deleted and recreated (UID changed).
    +		eval.FirstEvaluatedAt = &now
    +	}
    +
    +	// Taint timestamp transitions — four cases covering every state combination.
    +	// TaintRemovedAt is carried forward once set so the SLI is always queryable,
    +	// not just on the exact reconcile cycle where removal happened.
    +	if prev != nil && prev.RuleRef.UID == rule.GetUID() {
    +		prevTaintPresent := prev.TaintStatus == readinessv1alpha1.TaintStatusPresent
    +		if taintPresent && prevTaintPresent {
    +			// State unchanged: taint still active — carry forward all timestamps.
    +			eval.TaintObservedAt = prev.TaintObservedAt
    +			eval.TaintAddedAt = prev.TaintAddedAt
    +		} else if taintPresent && !prevTaintPresent {
    +			// Transition: Absent → Present — NRC just added the taint.
    +			eval.TaintObservedAt = &now
    +			eval.TaintAddedAt = &now
    +		} else if !taintPresent && prevTaintPresent {
    +			// Transition: Present → Absent — NRC just removed the taint.
    +			eval.TaintRemovedAt = &now
    +		} else {
    +			// State unchanged: taint still absent — carry forward historical removal time.
    +			eval.TaintRemovedAt = prev.TaintRemovedAt
    +		}
    +	} else if taintPresent {
    +		// First evaluation for this rule (or rule recreated) and taint is already
    +		// present — NRC is adopting a pre-existing taint.
    +		eval.TaintObservedAt = &now
    +		// TaintAddedAt stays nil — NRC did not add this taint.
    +	}
    +
    +	return eval
    +}
    +
    +// findPreviousRuleEvaluation returns the existing RuleEvaluation entry for the
    +// given rule name in the previous rules snapshot, or nil if not found.
    +func findPreviousRuleEvaluation(prevRules []readinessv1alpha1.RuleEvaluation, ruleName string) *readinessv1alpha1.RuleEvaluation {
    +	for i := range prevRules {
    +		if prevRules[i].RuleRef.Name == ruleName {
    +			return &prevRules[i]
    +		}
    +	}
    +	return nil
    +}
    +
    +// recomputeNREStatus derives status.State, status.Summary, and status.Conditions
    +// from the current rules slice. Called after every full rebuild so all top-level
    +// fields stay consistent.
    +func recomputeNREStatus(status *readinessv1alpha1.NodeReadinessEvaluationStatus) {
    +	var matched, unmatched, activeTaints, errors int32
    +
    +	for _, r := range status.Rules {
    +		switch r.RuleStatus {
    +		case readinessv1alpha1.RuleStatusMatched:
    +			matched++
    +		case readinessv1alpha1.RuleStatusUnmatched:
    +			unmatched++
    +		case readinessv1alpha1.RuleStatusError:
    +			errors++
    +		}
    +		if r.TaintStatus == readinessv1alpha1.TaintStatusPresent {
    +			activeTaints++
    +		}
    +	}
    +
    +	status.Summary = readinessv1alpha1.EvaluationSummary{
    +		MatchedRules:   &matched,
    +		UnmatchedRules: &unmatched,

    does 'unmatched' (node-selector escaped?) add value to the per-node status? As a node-owner I would less-likely be interested in rules that are not affecting my node.

    Imagine a large cluster with many different node-pools. Setting the status of a node in pool-A for other rules associated with every other pools may be rather confusing to the user.

    ajaysundark ajaysundark commented on code on Aug 24, 2026 07:48 UTC
    Code Review
    internal/controller/nodereadinessevaluation_controller.go:1
    @@ -0,0 +1,395 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package controller
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	corev1 "k8s.io/api/core/v1"
    +	apierrors "k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/runtime"
    +	"k8s.io/apimachinery/pkg/types"
    +	ctrl "sigs.k8s.io/controller-runtime"
    +	"sigs.k8s.io/controller-runtime/pkg/builder"
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
    +	"sigs.k8s.io/controller-runtime/pkg/event"
    +	"sigs.k8s.io/controller-runtime/pkg/handler"
    +	"sigs.k8s.io/controller-runtime/pkg/predicate"
    +	"sigs.k8s.io/controller-runtime/pkg/reconcile"
    +
    +	readinessv1alpha1 "sigs.k8s.io/node-readiness-controller/api/v1alpha1"
    +)
    +
    +// NodeReadinessEvaluationReconciler is an independent reconciler that maintains
    +// one NodeReadinessEvaluation object per Node. It watches Nodes and
    +// NodeReadinessRules and re-evaluates the full rule set for the affected node
    +// on every relevant change. It shares the rule cache owned by
    +// RuleReadinessController but never writes to Node taints or NRR status —
    +// those remain the sole responsibility of NodeReconciler / RuleReconciler.
    +type NodeReadinessEvaluationReconciler struct {
    +	client.Client
    +	Scheme     *runtime.Scheme
    +	Controller *RuleReadinessController
    +}
    +
    +// SetupWithManager wires the reconciler to watch:
    +//   - Node objects (conditions, taints, labels)
    +//   - NodeReadinessRule objects (enqueues all nodes matching the changed rule)
    +func (r *NodeReadinessEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error {

    I expect, adding another controller will also increase the API interaction volume to a larger extent at scale.

    ajaysundark ajaysundark commented on Aug 24, 2026 07:50 UTC
    Reviewer

    Thanks for looking into this @Karthik-K-N!

    Left some comments, mostly on the need for separate controller loop for NRE. We could find sometime to align on the implementation plan to avoid adding to your work and delaying this.

    ajaysundark ajaysundark commented on Aug 24, 2026 07:55 UTC
    Contributor

    NRE reconciler reads getApplicableRulesForNode, which serves only the private ruleCache, and the cache isn't populated until the rule controller's second reconcile

    Thanks for the callout @DsThakurRawat. agree, there are some risks with a managed cache and two controllers reconciling at two different snapshots of the cached data. we need to carefully handle the race-conditions.

    Karthik-K-N Karthik-K-N commented on code on Aug 24, 2026 15:32 UTC
    Code Review
    internal/controller/nodereadinessevaluation_controller.go:1
    @@ -0,0 +1,395 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package controller
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	corev1 "k8s.io/api/core/v1"
    +	apierrors "k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/runtime"
    +	"k8s.io/apimachinery/pkg/types"
    +	ctrl "sigs.k8s.io/controller-runtime"
    +	"sigs.k8s.io/controller-runtime/pkg/builder"
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
    +	"sigs.k8s.io/controller-runtime/pkg/event"
    +	"sigs.k8s.io/controller-runtime/pkg/handler"
    +	"sigs.k8s.io/controller-runtime/pkg/predicate"
    +	"sigs.k8s.io/controller-runtime/pkg/reconcile"
    +
    +	readinessv1alpha1 "sigs.k8s.io/node-readiness-controller/api/v1alpha1"
    +)
    +
    +// NodeReadinessEvaluationReconciler is an independent reconciler that maintains
    +// one NodeReadinessEvaluation object per Node. It watches Nodes and
    +// NodeReadinessRules and re-evaluates the full rule set for the affected node
    +// on every relevant change. It shares the rule cache owned by
    +// RuleReadinessController but never writes to Node taints or NRR status —
    +// those remain the sole responsibility of NodeReconciler / RuleReconciler.
    +type NodeReadinessEvaluationReconciler struct {
    +	client.Client
    +	Scheme     *runtime.Scheme
    +	Controller *RuleReadinessController
    +}
    +
    +// SetupWithManager wires the reconciler to watch:
    +//   - Node objects (conditions, taints, labels)
    +//   - NodeReadinessRule objects (enqueues all nodes matching the changed rule)
    +func (r *NodeReadinessEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error {

    I think if we can finalize on this aspect, then other things will be easy to tackle
    Since we use controller-runtime and it uses a Shared Informer Cache, additional controller does not increase API server watch traffic or our memory footprint. but It does duplicate the reconcile queue (may be CPU usage) and small window of race, but it provides less blast radius and separate of concern, we have two controller doing different things.
    Also I think we should consdier at what scale level we can expect this latency of having new controller

    Karthik-K-N Karthik-K-N commented on code on Aug 24, 2026 15:35 UTC
    Code Review
    internal/controller/nodereadinessevaluation_controller.go:1
    @@ -0,0 +1,395 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package controller
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	corev1 "k8s.io/api/core/v1"
    +	apierrors "k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/runtime"
    +	"k8s.io/apimachinery/pkg/types"
    +	ctrl "sigs.k8s.io/controller-runtime"
    +	"sigs.k8s.io/controller-runtime/pkg/builder"
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
    +	"sigs.k8s.io/controller-runtime/pkg/event"
    +	"sigs.k8s.io/controller-runtime/pkg/handler"
    +	"sigs.k8s.io/controller-runtime/pkg/predicate"
    +	"sigs.k8s.io/controller-runtime/pkg/reconcile"
    +
    +	readinessv1alpha1 "sigs.k8s.io/node-readiness-controller/api/v1alpha1"
    +)
    +
    +// NodeReadinessEvaluationReconciler is an independent reconciler that maintains
    +// one NodeReadinessEvaluation object per Node. It watches Nodes and
    +// NodeReadinessRules and re-evaluates the full rule set for the affected node
    +// on every relevant change. It shares the rule cache owned by
    +// RuleReadinessController but never writes to Node taints or NRR status —
    +// those remain the sole responsibility of NodeReconciler / RuleReconciler.
    +type NodeReadinessEvaluationReconciler struct {
    +	client.Client
    +	Scheme     *runtime.Scheme
    +	Controller *RuleReadinessController
    +}
    +
    +// SetupWithManager wires the reconciler to watch:
    +//   - Node objects (conditions, taints, labels)
    +//   - NodeReadinessRule objects (enqueues all nodes matching the changed rule)
    +func (r *NodeReadinessEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error {
    +	return ctrl.NewControllerManagedBy(mgr).
    +		Named("nodereadinessevaluation").
    +		// Primary watch: a node change triggers reconcile for that node's NRE.
    +		For(&corev1.Node{}, builder.WithPredicates(predicate.Funcs{
    +			CreateFunc: func(e event.CreateEvent) bool { return true },
    +			UpdateFunc: func(e event.UpdateEvent) bool {
    +				oldNode := e.ObjectOld.(*corev1.Node)
    +				newNode := e.ObjectNew.(*corev1.Node)
    +				return !conditionsEqual(oldNode.Status.Conditions, newNode.Status.Conditions) ||
    +					!taintsEqual(oldNode.Spec.Taints, newNode.Spec.Taints) ||
    +					!labelsEqual(oldNode.Labels, newNode.Labels)
    +			},
    +			DeleteFunc:  func(e event.DeleteEvent) bool { return false }, // GC handles deletion via ownerRef
    +			GenericFunc: func(e event.GenericEvent) bool { return false },
    +		})).
    +		// Secondary watch: a rule change re-evaluates every node in the cluster
    +		// that could be affected. We map the rule event to a list of node requests.
    +		Watches(
    +			&readinessv1alpha1.NodeReadinessRule{},
    +			handler.EnqueueRequestsFromMapFunc(r.ruleToNodeRequests),
    +			builder.WithPredicates(predicate.GenerationChangedPredicate{}),
    +		).
    +		Complete(r)
    +}
    +
    +// ruleToNodeRequests maps a NodeReadinessRule event to reconcile requests for
    +// only the Nodes that match the rule's nodeSelector. Filtering here avoids
    +// enqueueing the full cluster on every rule change — on a 5k-node cluster a
    +// rule targeting 200 nodes produces 200 requests, not 5,000.
    +//
    +// nodeSelector is immutable enforeced via CEL validateion on the spec, so a changing
    +// selector can never silently leave stale NRE entries behind.
    +func (r *NodeReadinessEvaluationReconciler) ruleToNodeRequests(ctx context.Context, obj client.Object) []reconcile.Request {
    +	log := ctrl.LoggerFrom(ctx)
    +
    +	rule, ok := obj.(*readinessv1alpha1.NodeReadinessRule)
    +	if !ok {
    +		return nil
    +	}
    +
    +	selector, err := metav1.LabelSelectorAsSelector(&rule.Spec.NodeSelector)
    +	if err != nil {
    +		// Invalid selector — the rule reconciler will surface this as an error;
    +		// nothing to enqueue here.
    +		log.Error(err, "invalid nodeSelector on rule, skipping NRE fan-out", "rule", rule.Name)
    +		return nil
    +	}
    +
    +	nodeList := &corev1.NodeList{}
    +	if err := r.List(ctx, nodeList, client.MatchingLabelsSelector{Selector: selector}); err != nil {
    +		log.Error(err, "failed to list matching nodes for NRE rule mapping", "rule", rule.Name)
    +		return nil
    +	}
    +
    +	requests := make([]reconcile.Request, len(nodeList.Items))
    +	for i, node := range nodeList.Items {
    +		requests[i] = reconcile.Request{
    +			NamespacedName: types.NamespacedName{Name: node.Name},
    +		}
    +	}
    +
    +	log.V(4).Info("Enqueuing NRE reconciles for rule change",
    +		"rule", rule.Name, "matchingNodes", len(requests))
    +	return requests
    +}
    +
    +// +kubebuilder:rbac:groups=readiness.node.x-k8s.io,resources=nodereadinessevaluations,verbs=get;list;watch;create;update;patch;delete
    +// +kubebuilder:rbac:groups=readiness.node.x-k8s.io,resources=nodereadinessevaluations/status,verbs=get;update;patch
    +
    +// Reconcile evaluates all applicable rules for the given node and writes the
    +// result into the corresponding NodeReadinessEvaluation object.
    +func (r *NodeReadinessEvaluationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
    +	log := ctrl.LoggerFrom(ctx)
    +	log.V(4).Info("Reconciling NodeReadinessEvaluation", "node", req.Name)
    +
    +	// Fetch the Node.
    +	node := &corev1.Node{}
    +	if err := r.Get(ctx, req.NamespacedName, node); err != nil {
    +		return ctrl.Result{}, client.IgnoreNotFound(err)
    +	}
    +
    +	// Fetch or create the NRE object.
    +	nre, err := r.ensureNRE(ctx, node)
    +	if err != nil {
    +		return ctrl.Result{}, err
    +	}
    +
    +	// Evaluate all applicable rules from the shared cache.
    +	applicableRules := r.Controller.getApplicableRulesForNode(ctx, node)
    +	log.V(4).Info("Evaluating rules for NRE", "node", node.Name, "ruleCount", len(applicableRules))
    +
    +	// Snapshot the previous rules slice for timestamp carry-forward BEFORE
    +	// clearing it. buildRuleEvaluation reads from this snapshot via nre.Status.Rules,
    +	// so it must not be cleared until after all evaluations are complete.
    +	prevRules := make([]readinessv1alpha1.RuleEvaluation, len(nre.Status.Rules))
    +	copy(prevRules, nre.Status.Rules)
    +
    +	patch := client.MergeFrom(nre.DeepCopy())
    +
    +	// Rebuild the full rules slice from scratch on every reconcile.
    +	// listType=atomic means the controller owns the whole slice.
    +	newRules := make([]readinessv1alpha1.RuleEvaluation, 0, len(applicableRules))
    +	for _, rule := range applicableRules {
    +		if !rule.DeletionTimestamp.IsZero() || rule.Spec.DryRun {
    +			continue
    +		}
    +		ruleEval := r.buildRuleEvaluation(ctx, node, rule, prevRules)
    +		newRules = append(newRules, ruleEval)
    +	}
    +	nre.Status.Rules = newRules
    +
    +	recomputeNREStatus(&nre.Status)
    +
    +	if err := r.Status().Patch(ctx, nre, patch); err != nil {
    +		return ctrl.Result{}, fmt.Errorf("failed to patch NRE status %s: %w", node.Name, err)
    +	}
    +
    +	log.V(4).Info("Reconciled NRE", "node", node.Name, "rules", len(nre.Status.Rules), "state", nre.Status.State)
    +	return ctrl.Result{}, nil
    +}
    +
    +// ensureNRE fetches the NRE for the node, creating it (with ownerReference) if
    +// it does not exist yet. Returns the current object ready for status patching.
    +func (r *NodeReadinessEvaluationReconciler) ensureNRE(ctx context.Context, node *corev1.Node) (*readinessv1alpha1.NodeReadinessEvaluation, error) {
    +	nre := &readinessv1alpha1.NodeReadinessEvaluation{}
    +	err := r.Get(ctx, client.ObjectKey{Name: node.Name}, nre)
    +
    +	switch {
    +	case apierrors.IsNotFound(err):
    +		nre = &readinessv1alpha1.NodeReadinessEvaluation{
    +			ObjectMeta: metav1.ObjectMeta{
    +				Name: node.Name,
    +			},
    +			Spec: readinessv1alpha1.NodeReadinessEvaluationSpec{
    +				NodeName: node.Name,
    +			},
    +		}
    +		if ownerErr := controllerutil.SetOwnerReference(node, nre, r.Scheme); ownerErr != nil {
    +			return nil, fmt.Errorf("failed to set owner reference on NRE %s: %w", node.Name, ownerErr)
    +		}
    +		if createErr := r.Create(ctx, nre); createErr != nil {
    +			if !apierrors.IsAlreadyExists(createErr) {
    +				return nil, fmt.Errorf("failed to create NRE %s: %w", node.Name, createErr)
    +			}
    +			// A concurrent reconcile won the race — re-fetch.
    +			if getErr := r.Get(ctx, client.ObjectKey{Name: node.Name}, nre); getErr != nil {
    +				return nil, fmt.Errorf("failed to get NRE %s after AlreadyExists: %w", node.Name, getErr)
    +			}
    +		}
    +		ctrl.LoggerFrom(ctx).V(4).Info("Created NodeReadinessEvaluation", "nre", node.Name)
    +
    +	case err != nil:
    +		return nil, fmt.Errorf("failed to get NRE %s: %w", node.Name, err)
    +	}
    +
    +	return nre, nil
    +}
    +
    +// buildRuleEvaluation evaluates a single rule against the node and constructs
    +// the RuleEvaluation entry, preserving SLI timestamps from prevRules (the
    +// snapshot of the previous status.rules slice taken before the rebuild started).
    +func (r *NodeReadinessEvaluationReconciler) buildRuleEvaluation(
    +	ctx context.Context,
    +	node *corev1.Node,
    +	rule *readinessv1alpha1.NodeReadinessRule,
    +	prevRules []readinessv1alpha1.RuleEvaluation,
    +) readinessv1alpha1.RuleEvaluation {
    +	log := ctrl.LoggerFrom(ctx)
    +	now := metav1.Now()
    +
    +	// Evaluate all conditions.
    +	allConditionsSatisfied := true
    +	conditionResults := make([]readinessv1alpha1.ConditionEvaluationResult, 0, len(rule.Spec.Conditions))
    +	for _, condReq := range rule.Spec.Conditions {
    +		effectiveStatus, conditionFound := r.Controller.getConditionStatus(node, condReq.Type, condReq.GetDefaultStatus())
    +		satisfied := effectiveStatus == condReq.RequiredStatus
    +		if !satisfied {
    +			allConditionsSatisfied = false
    +		}
    +		observedStatus := effectiveStatus
    +		if !conditionFound {
    +			observedStatus = corev1.ConditionUnknown
    +		}
    +		conditionResults = append(conditionResults, readinessv1alpha1.ConditionEvaluationResult{
    +			Type:           condReq.Type,
    +			CurrentStatus:  observedStatus,
    +			RequiredStatus: condReq.RequiredStatus,
    +			DefaultStatus:  condReq.GetDefaultStatus(),
    +		})
    +	}
    +
    +	ruleStatus := readinessv1alpha1.RuleStatusMatched
    +	if !allConditionsSatisfied {
    +		ruleStatus = readinessv1alpha1.RuleStatusUnmatched
    +	}
    +
    +	taintPresent := r.Controller.hasTaintBySpec(node, rule.Spec.Taint)
    +	taintStatus := readinessv1alpha1.TaintStatusAbsent
    +	if taintPresent {
    +		taintStatus = readinessv1alpha1.TaintStatusPresent
    +	}
    +
    +	log.V(4).Info("Rule evaluation for NRE",
    +		"node", node.Name, "rule", rule.Name,
    +		"ruleStatus", ruleStatus, "taintStatus", taintStatus)
    +
    +	// Carry forward timestamps from the previous evaluation entry if present.
    +	prev := findPreviousRuleEvaluation(prevRules, rule.Name)
    +
    +	eval := readinessv1alpha1.RuleEvaluation{
    +		RuleRef: readinessv1alpha1.RuleRef{
    +			Name: rule.Name,
    +			UID:  rule.GetUID(),
    +		},
    +		RuleStatus:          ruleStatus,
    +		TaintStatus:         taintStatus,
    +		ReadinessConditions: conditionResults,
    +		LastEvaluationTime:  now,
    +	}
    +
    +	// FirstEvaluatedAt: set once, carried forward on subsequent evaluations.
    +	if prev != nil && prev.RuleRef.UID == rule.GetUID() {
    +		eval.FirstEvaluatedAt = prev.FirstEvaluatedAt
    +	} else {
    +		// No previous entry, or the rule was deleted and recreated (UID changed).
    +		eval.FirstEvaluatedAt = &now
    +	}
    +
    +	// Taint timestamp transitions — four cases covering every state combination.
    +	// TaintRemovedAt is carried forward once set so the SLI is always queryable,
    +	// not just on the exact reconcile cycle where removal happened.
    +	if prev != nil && prev.RuleRef.UID == rule.GetUID() {
    +		prevTaintPresent := prev.TaintStatus == readinessv1alpha1.TaintStatusPresent
    +		if taintPresent && prevTaintPresent {
    +			// State unchanged: taint still active — carry forward all timestamps.
    +			eval.TaintObservedAt = prev.TaintObservedAt
    +			eval.TaintAddedAt = prev.TaintAddedAt
    +		} else if taintPresent && !prevTaintPresent {
    +			// Transition: Absent → Present — NRC just added the taint.
    +			eval.TaintObservedAt = &now
    +			eval.TaintAddedAt = &now
    +		} else if !taintPresent && prevTaintPresent {
    +			// Transition: Present → Absent — NRC just removed the taint.
    +			eval.TaintRemovedAt = &now
    +		} else {
    +			// State unchanged: taint still absent — carry forward historical removal time.
    +			eval.TaintRemovedAt = prev.TaintRemovedAt
    +		}
    +	} else if taintPresent {
    +		// First evaluation for this rule (or rule recreated) and taint is already
    +		// present — NRC is adopting a pre-existing taint.
    +		eval.TaintObservedAt = &now
    +		// TaintAddedAt stays nil — NRC did not add this taint.
    +	}
    +
    +	return eval
    +}
    +
    +// findPreviousRuleEvaluation returns the existing RuleEvaluation entry for the
    +// given rule name in the previous rules snapshot, or nil if not found.
    +func findPreviousRuleEvaluation(prevRules []readinessv1alpha1.RuleEvaluation, ruleName string) *readinessv1alpha1.RuleEvaluation {
    +	for i := range prevRules {
    +		if prevRules[i].RuleRef.Name == ruleName {
    +			return &prevRules[i]
    +		}
    +	}
    +	return nil
    +}
    +
    +// recomputeNREStatus derives status.State, status.Summary, and status.Conditions
    +// from the current rules slice. Called after every full rebuild so all top-level
    +// fields stay consistent.
    +func recomputeNREStatus(status *readinessv1alpha1.NodeReadinessEvaluationStatus) {
    +	var matched, unmatched, activeTaints, errors int32
    +
    +	for _, r := range status.Rules {
    +		switch r.RuleStatus {
    +		case readinessv1alpha1.RuleStatusMatched:
    +			matched++
    +		case readinessv1alpha1.RuleStatusUnmatched:
    +			unmatched++
    +		case readinessv1alpha1.RuleStatusError:
    +			errors++
    +		}
    +		if r.TaintStatus == readinessv1alpha1.TaintStatusPresent {
    +			activeTaints++
    +		}
    +	}
    +
    +	status.Summary = readinessv1alpha1.EvaluationSummary{
    +		MatchedRules:   &matched,
    +		UnmatchedRules: &unmatched,

    True, I think we can drop the UnmatchedRules field.

    Karthik-K-N Karthik-K-N commented on code on Aug 24, 2026 15:42 UTC
    Code Review
    internal/controller/nodereadinessevaluation_controller.go:1
    @@ -0,0 +1,395 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package controller
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	corev1 "k8s.io/api/core/v1"
    +	apierrors "k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/runtime"
    +	"k8s.io/apimachinery/pkg/types"
    +	ctrl "sigs.k8s.io/controller-runtime"
    +	"sigs.k8s.io/controller-runtime/pkg/builder"
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
    +	"sigs.k8s.io/controller-runtime/pkg/event"
    +	"sigs.k8s.io/controller-runtime/pkg/handler"
    +	"sigs.k8s.io/controller-runtime/pkg/predicate"
    +	"sigs.k8s.io/controller-runtime/pkg/reconcile"
    +
    +	readinessv1alpha1 "sigs.k8s.io/node-readiness-controller/api/v1alpha1"
    +)
    +
    +// NodeReadinessEvaluationReconciler is an independent reconciler that maintains
    +// one NodeReadinessEvaluation object per Node. It watches Nodes and
    +// NodeReadinessRules and re-evaluates the full rule set for the affected node
    +// on every relevant change. It shares the rule cache owned by
    +// RuleReadinessController but never writes to Node taints or NRR status —
    +// those remain the sole responsibility of NodeReconciler / RuleReconciler.
    +type NodeReadinessEvaluationReconciler struct {
    +	client.Client
    +	Scheme     *runtime.Scheme
    +	Controller *RuleReadinessController
    +}
    +
    +// SetupWithManager wires the reconciler to watch:
    +//   - Node objects (conditions, taints, labels)
    +//   - NodeReadinessRule objects (enqueues all nodes matching the changed rule)
    +func (r *NodeReadinessEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error {
    +	return ctrl.NewControllerManagedBy(mgr).
    +		Named("nodereadinessevaluation").
    +		// Primary watch: a node change triggers reconcile for that node's NRE.
    +		For(&corev1.Node{}, builder.WithPredicates(predicate.Funcs{
    +			CreateFunc: func(e event.CreateEvent) bool { return true },
    +			UpdateFunc: func(e event.UpdateEvent) bool {
    +				oldNode := e.ObjectOld.(*corev1.Node)
    +				newNode := e.ObjectNew.(*corev1.Node)
    +				return !conditionsEqual(oldNode.Status.Conditions, newNode.Status.Conditions) ||
    +					!taintsEqual(oldNode.Spec.Taints, newNode.Spec.Taints) ||
    +					!labelsEqual(oldNode.Labels, newNode.Labels)
    +			},
    +			DeleteFunc:  func(e event.DeleteEvent) bool { return false }, // GC handles deletion via ownerRef
    +			GenericFunc: func(e event.GenericEvent) bool { return false },
    +		})).
    +		// Secondary watch: a rule change re-evaluates every node in the cluster
    +		// that could be affected. We map the rule event to a list of node requests.
    +		Watches(
    +			&readinessv1alpha1.NodeReadinessRule{},
    +			handler.EnqueueRequestsFromMapFunc(r.ruleToNodeRequests),
    +			builder.WithPredicates(predicate.GenerationChangedPredicate{}),
    +		).
    +		Complete(r)
    +}
    +
    +// ruleToNodeRequests maps a NodeReadinessRule event to reconcile requests for
    +// only the Nodes that match the rule's nodeSelector. Filtering here avoids
    +// enqueueing the full cluster on every rule change — on a 5k-node cluster a
    +// rule targeting 200 nodes produces 200 requests, not 5,000.
    +//
    +// nodeSelector is immutable enforeced via CEL validateion on the spec, so a changing
    +// selector can never silently leave stale NRE entries behind.
    +func (r *NodeReadinessEvaluationReconciler) ruleToNodeRequests(ctx context.Context, obj client.Object) []reconcile.Request {
    +	log := ctrl.LoggerFrom(ctx)
    +
    +	rule, ok := obj.(*readinessv1alpha1.NodeReadinessRule)
    +	if !ok {
    +		return nil
    +	}
    +
    +	selector, err := metav1.LabelSelectorAsSelector(&rule.Spec.NodeSelector)
    +	if err != nil {
    +		// Invalid selector — the rule reconciler will surface this as an error;
    +		// nothing to enqueue here.
    +		log.Error(err, "invalid nodeSelector on rule, skipping NRE fan-out", "rule", rule.Name)
    +		return nil
    +	}
    +
    +	nodeList := &corev1.NodeList{}
    +	if err := r.List(ctx, nodeList, client.MatchingLabelsSelector{Selector: selector}); err != nil {
    +		log.Error(err, "failed to list matching nodes for NRE rule mapping", "rule", rule.Name)
    +		return nil
    +	}
    +
    +	requests := make([]reconcile.Request, len(nodeList.Items))
    +	for i, node := range nodeList.Items {
    +		requests[i] = reconcile.Request{
    +			NamespacedName: types.NamespacedName{Name: node.Name},
    +		}
    +	}
    +
    +	log.V(4).Info("Enqueuing NRE reconciles for rule change",
    +		"rule", rule.Name, "matchingNodes", len(requests))
    +	return requests
    +}
    +
    +// +kubebuilder:rbac:groups=readiness.node.x-k8s.io,resources=nodereadinessevaluations,verbs=get;list;watch;create;update;patch;delete
    +// +kubebuilder:rbac:groups=readiness.node.x-k8s.io,resources=nodereadinessevaluations/status,verbs=get;update;patch
    +
    +// Reconcile evaluates all applicable rules for the given node and writes the
    +// result into the corresponding NodeReadinessEvaluation object.
    +func (r *NodeReadinessEvaluationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
    +	log := ctrl.LoggerFrom(ctx)
    +	log.V(4).Info("Reconciling NodeReadinessEvaluation", "node", req.Name)
    +
    +	// Fetch the Node.
    +	node := &corev1.Node{}
    +	if err := r.Get(ctx, req.NamespacedName, node); err != nil {
    +		return ctrl.Result{}, client.IgnoreNotFound(err)
    +	}
    +
    +	// Fetch or create the NRE object.
    +	nre, err := r.ensureNRE(ctx, node)
    +	if err != nil {
    +		return ctrl.Result{}, err
    +	}
    +
    +	// Evaluate all applicable rules from the shared cache.
    +	applicableRules := r.Controller.getApplicableRulesForNode(ctx, node)
    +	log.V(4).Info("Evaluating rules for NRE", "node", node.Name, "ruleCount", len(applicableRules))
    +
    +	// Snapshot the previous rules slice for timestamp carry-forward BEFORE
    +	// clearing it. buildRuleEvaluation reads from this snapshot via nre.Status.Rules,
    +	// so it must not be cleared until after all evaluations are complete.
    +	prevRules := make([]readinessv1alpha1.RuleEvaluation, len(nre.Status.Rules))
    +	copy(prevRules, nre.Status.Rules)
    +
    +	patch := client.MergeFrom(nre.DeepCopy())
    +
    +	// Rebuild the full rules slice from scratch on every reconcile.
    +	// listType=atomic means the controller owns the whole slice.
    +	newRules := make([]readinessv1alpha1.RuleEvaluation, 0, len(applicableRules))
    +	for _, rule := range applicableRules {
    +		if !rule.DeletionTimestamp.IsZero() || rule.Spec.DryRun {
    +			continue
    +		}
    +		ruleEval := r.buildRuleEvaluation(ctx, node, rule, prevRules)
    +		newRules = append(newRules, ruleEval)
    +	}
    +	nre.Status.Rules = newRules
    +
    +	recomputeNREStatus(&nre.Status)
    +
    +	if err := r.Status().Patch(ctx, nre, patch); err != nil {
    +		return ctrl.Result{}, fmt.Errorf("failed to patch NRE status %s: %w", node.Name, err)
    +	}
    +
    +	log.V(4).Info("Reconciled NRE", "node", node.Name, "rules", len(nre.Status.Rules), "state", nre.Status.State)
    +	return ctrl.Result{}, nil
    +}
    +
    +// ensureNRE fetches the NRE for the node, creating it (with ownerReference) if
    +// it does not exist yet. Returns the current object ready for status patching.
    +func (r *NodeReadinessEvaluationReconciler) ensureNRE(ctx context.Context, node *corev1.Node) (*readinessv1alpha1.NodeReadinessEvaluation, error) {
    +	nre := &readinessv1alpha1.NodeReadinessEvaluation{}
    +	err := r.Get(ctx, client.ObjectKey{Name: node.Name}, nre)
    +
    +	switch {
    +	case apierrors.IsNotFound(err):
    +		nre = &readinessv1alpha1.NodeReadinessEvaluation{
    +			ObjectMeta: metav1.ObjectMeta{
    +				Name: node.Name,
    +			},
    +			Spec: readinessv1alpha1.NodeReadinessEvaluationSpec{
    +				NodeName: node.Name,
    +			},
    +		}
    +		if ownerErr := controllerutil.SetOwnerReference(node, nre, r.Scheme); ownerErr != nil {
    +			return nil, fmt.Errorf("failed to set owner reference on NRE %s: %w", node.Name, ownerErr)
    +		}
    +		if createErr := r.Create(ctx, nre); createErr != nil {
    +			if !apierrors.IsAlreadyExists(createErr) {
    +				return nil, fmt.Errorf("failed to create NRE %s: %w", node.Name, createErr)
    +			}
    +			// A concurrent reconcile won the race — re-fetch.
    +			if getErr := r.Get(ctx, client.ObjectKey{Name: node.Name}, nre); getErr != nil {
    +				return nil, fmt.Errorf("failed to get NRE %s after AlreadyExists: %w", node.Name, getErr)
    +			}
    +		}
    +		ctrl.LoggerFrom(ctx).V(4).Info("Created NodeReadinessEvaluation", "nre", node.Name)
    +
    +	case err != nil:
    +		return nil, fmt.Errorf("failed to get NRE %s: %w", node.Name, err)
    +	}
    +
    +	return nre, nil
    +}
    +
    +// buildRuleEvaluation evaluates a single rule against the node and constructs
    +// the RuleEvaluation entry, preserving SLI timestamps from prevRules (the
    +// snapshot of the previous status.rules slice taken before the rebuild started).
    +func (r *NodeReadinessEvaluationReconciler) buildRuleEvaluation(
    +	ctx context.Context,
    +	node *corev1.Node,
    +	rule *readinessv1alpha1.NodeReadinessRule,
    +	prevRules []readinessv1alpha1.RuleEvaluation,
    +) readinessv1alpha1.RuleEvaluation {
    +	log := ctrl.LoggerFrom(ctx)
    +	now := metav1.Now()
    +
    +	// Evaluate all conditions.
    +	allConditionsSatisfied := true
    +	conditionResults := make([]readinessv1alpha1.ConditionEvaluationResult, 0, len(rule.Spec.Conditions))
    +	for _, condReq := range rule.Spec.Conditions {
    +		effectiveStatus, conditionFound := r.Controller.getConditionStatus(node, condReq.Type, condReq.GetDefaultStatus())
    +		satisfied := effectiveStatus == condReq.RequiredStatus
    +		if !satisfied {
    +			allConditionsSatisfied = false
    +		}
    +		observedStatus := effectiveStatus
    +		if !conditionFound {
    +			observedStatus = corev1.ConditionUnknown
    +		}
    +		conditionResults = append(conditionResults, readinessv1alpha1.ConditionEvaluationResult{
    +			Type:           condReq.Type,
    +			CurrentStatus:  observedStatus,
    +			RequiredStatus: condReq.RequiredStatus,
    +			DefaultStatus:  condReq.GetDefaultStatus(),
    +		})
    +	}
    +
    +	ruleStatus := readinessv1alpha1.RuleStatusMatched
    +	if !allConditionsSatisfied {
    +		ruleStatus = readinessv1alpha1.RuleStatusUnmatched
    +	}
    +
    +	taintPresent := r.Controller.hasTaintBySpec(node, rule.Spec.Taint)
    +	taintStatus := readinessv1alpha1.TaintStatusAbsent
    +	if taintPresent {
    +		taintStatus = readinessv1alpha1.TaintStatusPresent
    +	}
    +
    +	log.V(4).Info("Rule evaluation for NRE",
    +		"node", node.Name, "rule", rule.Name,
    +		"ruleStatus", ruleStatus, "taintStatus", taintStatus)
    +
    +	// Carry forward timestamps from the previous evaluation entry if present.
    +	prev := findPreviousRuleEvaluation(prevRules, rule.Name)
    +
    +	eval := readinessv1alpha1.RuleEvaluation{
    +		RuleRef: readinessv1alpha1.RuleRef{
    +			Name: rule.Name,
    +			UID:  rule.GetUID(),
    +		},
    +		RuleStatus:          ruleStatus,
    +		TaintStatus:         taintStatus,
    +		ReadinessConditions: conditionResults,
    +		LastEvaluationTime:  now,
    +	}
    +
    +	// FirstEvaluatedAt: set once, carried forward on subsequent evaluations.
    +	if prev != nil && prev.RuleRef.UID == rule.GetUID() {
    +		eval.FirstEvaluatedAt = prev.FirstEvaluatedAt
    +	} else {
    +		// No previous entry, or the rule was deleted and recreated (UID changed).
    +		eval.FirstEvaluatedAt = &now
    +	}
    +
    +	// Taint timestamp transitions — four cases covering every state combination.
    +	// TaintRemovedAt is carried forward once set so the SLI is always queryable,
    +	// not just on the exact reconcile cycle where removal happened.
    +	if prev != nil && prev.RuleRef.UID == rule.GetUID() {
    +		prevTaintPresent := prev.TaintStatus == readinessv1alpha1.TaintStatusPresent
    +		if taintPresent && prevTaintPresent {
    +			// State unchanged: taint still active — carry forward all timestamps.
    +			eval.TaintObservedAt = prev.TaintObservedAt
    +			eval.TaintAddedAt = prev.TaintAddedAt
    +		} else if taintPresent && !prevTaintPresent {
    +			// Transition: Absent → Present — NRC just added the taint.
    +			eval.TaintObservedAt = &now
    +			eval.TaintAddedAt = &now
    +		} else if !taintPresent && prevTaintPresent {
    +			// Transition: Present → Absent — NRC just removed the taint.
    +			eval.TaintRemovedAt = &now
    +		} else {
    +			// State unchanged: taint still absent — carry forward historical removal time.
    +			eval.TaintRemovedAt = prev.TaintRemovedAt
    +		}
    +	} else if taintPresent {
    +		// First evaluation for this rule (or rule recreated) and taint is already
    +		// present — NRC is adopting a pre-existing taint.
    +		eval.TaintObservedAt = &now
    +		// TaintAddedAt stays nil — NRC did not add this taint.
    +	}
    +
    +	return eval
    +}
    +
    +// findPreviousRuleEvaluation returns the existing RuleEvaluation entry for the
    +// given rule name in the previous rules snapshot, or nil if not found.
    +func findPreviousRuleEvaluation(prevRules []readinessv1alpha1.RuleEvaluation, ruleName string) *readinessv1alpha1.RuleEvaluation {
    +	for i := range prevRules {
    +		if prevRules[i].RuleRef.Name == ruleName {
    +			return &prevRules[i]
    +		}
    +	}
    +	return nil
    +}
    +
    +// recomputeNREStatus derives status.State, status.Summary, and status.Conditions
    +// from the current rules slice. Called after every full rebuild so all top-level
    +// fields stay consistent.
    +func recomputeNREStatus(status *readinessv1alpha1.NodeReadinessEvaluationStatus) {
    +	var matched, unmatched, activeTaints, errors int32
    +
    +	for _, r := range status.Rules {
    +		switch r.RuleStatus {
    +		case readinessv1alpha1.RuleStatusMatched:

    So the RuleStatus field helps to understand "whether node satisfy every condition listed in the rule"
    Matched - All rule.Spec.Conditions are satisfied - ideally no taint
    Unmatched - Any condition is not satisfied - there is taint on node

    Do you think we should use better field name to convey this?

    Instead of Matched should I change that to RuleStatusSatisfied means the rule is satisfied by the node?

    yindia yindia commented on Aug 25, 2026 13:32 UTC
    Contributor

    @ajaysundark On the cache-ordering window: reading rules via an informer List in Reconcile, instead of the private ruleCache, closes it. The fan-out fires on the rule watch event, so the informer already has the new rule, whereas ruleCache isn't written until RuleReconciler's second pass. It also drops the ordering dependency, with no need to remove ruleCache itself. wdyt ?

    ajaysundark ajaysundark commented on code on Aug 30, 2026 05:29 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.

    Is it possible to get Ready=False AND Evaluated=True on a NREStatus? I'm trying to see whether Evaluated is functionally identical signal as Ready or how it should be interpreted.

    ajaysundark ajaysundark commented on code on Aug 30, 2026 05:33 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.

    Do I understand your comments correctly: you think Evaluated=False suggests 'errors' processing this node with NRC, whereas Ready=False means Taint is present (pending readiness on this node). So a normal user would subscribe to "kubectl wait --for=condition=Ready".

    who / how do you see Evaluated should be consumed? and could you also clarify what 'errors' do you see this to be. is it like permission (for eg: to remove taint) or something else?

    ajaysundark ajaysundark commented on code on Aug 30, 2026 05:38 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.

    is this needed in addition to Ready=True/False/Unknown to show combinational status (compose all rule outcomes)? your comments seem to map to True, False & Unknown respectively.

    ajaysundark ajaysundark commented on code on Aug 30, 2026 05:44 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100
    +	Rules []RuleEvaluation `json:"rules,omitempty"`
    +}
    +
    +// RuleRef identifies a NodeReadinessRule by its name and UID.
    +// Bundling both fields into a single struct makes the identity unit explicit and
    +// mirrors the pattern used by metav1.OwnerReference.
    +type RuleRef struct {
    +	// name is the name of the NodeReadinessRule.
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	Name string `json:"name,omitempty"`
    +
    +	// uid is the UID of the NodeReadinessRule.
    +	// If the rule is deleted and recreated with the same name, the UID will differ,
    +	// allowing the controller to detect and replace stale evaluation entries.
    +	//
    +	// +required
    +	UID types.UID `json:"uid,omitempty"`
    +}
    +
    +// RuleEvaluation defines the outcome of evaluating a single NodeReadinessRule against this Node.
    +type RuleEvaluation struct {
    +	// ruleRef identifies the NodeReadinessRule this evaluation applies to.
    +	// It bundles the rule's name (human-readable) and UID (tamper-proof identity)
    +	// so that delete-and-recreate of a same-named rule is always detectable.
    +	//
    +	// +required
    +	RuleRef RuleRef `json:"ruleRef,omitempty,omitzero"`
    +
    +	// ruleStatus indicates the overall outcome of the rule's criteria against the Node.
    +	//
    +	// +required
    +	RuleStatus RuleStatus `json:"ruleStatus,omitempty"`
    +
    +	// taintStatus reflects the observed state of the rule's specified taint on the Node (Present/Absent).
    +	//
    +	// +required
    +	TaintStatus TaintStatus `json:"taintStatus,omitempty"`
    +
    +	// reason contains a concise, machine-readable string detailing the primary outcome.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=256
    +	Reason string `json:"reason,omitempty"`
    +
    +	// message is a comprehensive, human-readable explanation providing further context.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=10240
    +	Message string `json:"message,omitempty"`
    +
    +	// readinessConditions provides a detailed breakdown of each condition evaluation
    +	// for this Node. This allows for granular debugging of which specific criteria passed/failed.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=32
    +	ReadinessConditions []ConditionEvaluationResult `json:"readinessConditions,omitempty"`
    +
    +	// lastEvaluationTime records the exact moment the controller most recently assessed this rule.
    +	//
    +	// +required
    +	LastEvaluationTime metav1.Time `json:"lastEvaluationTime,omitempty,omitzero"`
    +
    +	// firstEvaluatedAt is the time the rule was first assessed against this node.
    +	//
    +	// +optional
    +	FirstEvaluatedAt *metav1.Time `json:"firstEvaluatedAt,omitempty"`
    +
    +	// taintObservedAt is the time NRC first observed the taint present on the node,
    +	// regardless of whether NRC applied it or it was pre-existing (e.g. via --register-with-taints).
    +	// This marks the beginning of the node being blocked by this rule and is the correct
    +	// start time for computing time-to-unblock SLIs.
    +	//
    +	// +optional
    +	TaintObservedAt *metav1.Time `json:"taintObservedAt,omitempty"`
    +
    +	// taintAddedAt is the time NRC itself applied the taint to the node.
    +	// This field is nil when the taint was pre-existing and NRC adopted it rather than creating it.
    +	// Use taintObservedAt for "how long has the node been blocked"; use this field to measure
    +	// NRC's own apply latency (taintAddedAt - firstEvaluatedAt).
    +	//
    +	// +optional
    +	TaintAddedAt *metav1.Time `json:"taintAddedAt,omitempty"`
    +
    +	// taintRemovedAt is the time the controller successfully removed the taint
    +	// after the node satisfied all conditions.
    +	//
    +	// +optional
    +	TaintRemovedAt *metav1.Time `json:"taintRemovedAt,omitempty"`
    +}
    +
    +// EvaluationSummary aggregates the results to provide a high-level overview.
    +// +kubebuilder:validation:MinProperties=1
    +type EvaluationSummary struct {

    I understand why you want this top level summary object here.

    Maybe I am being extra careful since we are now moving out of a collapsing entity to isolated objects -- do we want this summary at the top, or is this something we could plan later? since we anticipate a handful or <10 rule matchings per node, I wonder if we could get away with having only the Conditions and RuleEvaluation[] array here?

    ajaysundark ajaysundark commented on code on Aug 30, 2026 05:50 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100
    +	Rules []RuleEvaluation `json:"rules,omitempty"`
    +}
    +
    +// RuleRef identifies a NodeReadinessRule by its name and UID.
    +// Bundling both fields into a single struct makes the identity unit explicit and
    +// mirrors the pattern used by metav1.OwnerReference.
    +type RuleRef struct {
    +	// name is the name of the NodeReadinessRule.
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	Name string `json:"name,omitempty"`
    +
    +	// uid is the UID of the NodeReadinessRule.
    +	// If the rule is deleted and recreated with the same name, the UID will differ,
    +	// allowing the controller to detect and replace stale evaluation entries.
    +	//
    +	// +required
    +	UID types.UID `json:"uid,omitempty"`
    +}
    +
    +// RuleEvaluation defines the outcome of evaluating a single NodeReadinessRule against this Node.
    +type RuleEvaluation struct {
    +	// ruleRef identifies the NodeReadinessRule this evaluation applies to.
    +	// It bundles the rule's name (human-readable) and UID (tamper-proof identity)
    +	// so that delete-and-recreate of a same-named rule is always detectable.
    +	//
    +	// +required
    +	RuleRef RuleRef `json:"ruleRef,omitempty,omitzero"`

    super nit: could we keep RuleName and RuleUID directly here? Since these are keys to these objects, avoiding an extra deref would be more convenient for the consumers.

    ajaysundark ajaysundark commented on code on Aug 30, 2026 05:52 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100

    NA - I'm not suggesting to change this. but I'll be worried about a node having to deal with 100 taints!~ .

    ajaysundark ajaysundark commented on code on Aug 30, 2026 05:52 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic

    listType=map with Key=ruleName?

    ajaysundark ajaysundark commented on code on Aug 30, 2026 05:59 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"

    Trying to compare with the states we introduced here: https://github.com/kubernetes-sigs/node-readiness-controller/pull/344.

    We added new state conventions for nodes: 'held' vs 'released' - but I think we saw them as "node's" state per rule. these are rule's state so "satisfied" makes sense. is that how you're thinking?

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:02 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).

    how will unparseable NodeSelector error is attributable to any specific node? I think rule-configuration error on the node's evaluation error is confusing.

    I could imagine a more generic 'Blocked' for RuleStatus on the node - but then the question about - when do we decide unsatisfied vs blocked comes up as we do not have any 'time' budget on the rule-reconciliation.

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:08 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100
    +	Rules []RuleEvaluation `json:"rules,omitempty"`
    +}
    +
    +// RuleRef identifies a NodeReadinessRule by its name and UID.
    +// Bundling both fields into a single struct makes the identity unit explicit and
    +// mirrors the pattern used by metav1.OwnerReference.
    +type RuleRef struct {
    +	// name is the name of the NodeReadinessRule.
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	Name string `json:"name,omitempty"`
    +
    +	// uid is the UID of the NodeReadinessRule.
    +	// If the rule is deleted and recreated with the same name, the UID will differ,
    +	// allowing the controller to detect and replace stale evaluation entries.
    +	//
    +	// +required
    +	UID types.UID `json:"uid,omitempty"`
    +}
    +
    +// RuleEvaluation defines the outcome of evaluating a single NodeReadinessRule against this Node.
    +type RuleEvaluation struct {
    +	// ruleRef identifies the NodeReadinessRule this evaluation applies to.
    +	// It bundles the rule's name (human-readable) and UID (tamper-proof identity)
    +	// so that delete-and-recreate of a same-named rule is always detectable.
    +	//
    +	// +required
    +	RuleRef RuleRef `json:"ruleRef,omitempty,omitzero"`
    +
    +	// ruleStatus indicates the overall outcome of the rule's criteria against the Node.
    +	//
    +	// +required
    +	RuleStatus RuleStatus `json:"ruleStatus,omitempty"`
    +

    should we add the taintKey/effect here to help for self-reporting (instead of the active taints 'count' at the summary)?

    I dunno, it would be redundant to rule.spec.taint, but for the headlamp kind of clients we are building, the CR may give a singular view of the readiness state on a 'node' level, without have to lookup again on the rule).

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:10 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100
    +	Rules []RuleEvaluation `json:"rules,omitempty"`
    +}
    +
    +// RuleRef identifies a NodeReadinessRule by its name and UID.
    +// Bundling both fields into a single struct makes the identity unit explicit and
    +// mirrors the pattern used by metav1.OwnerReference.
    +type RuleRef struct {
    +	// name is the name of the NodeReadinessRule.
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	Name string `json:"name,omitempty"`
    +
    +	// uid is the UID of the NodeReadinessRule.
    +	// If the rule is deleted and recreated with the same name, the UID will differ,
    +	// allowing the controller to detect and replace stale evaluation entries.
    +	//
    +	// +required
    +	UID types.UID `json:"uid,omitempty"`
    +}
    +
    +// RuleEvaluation defines the outcome of evaluating a single NodeReadinessRule against this Node.
    +type RuleEvaluation struct {
    +	// ruleRef identifies the NodeReadinessRule this evaluation applies to.
    +	// It bundles the rule's name (human-readable) and UID (tamper-proof identity)
    +	// so that delete-and-recreate of a same-named rule is always detectable.
    +	//
    +	// +required
    +	RuleRef RuleRef `json:"ruleRef,omitempty,omitzero"`
    +
    +	// ruleStatus indicates the overall outcome of the rule's criteria against the Node.
    +	//
    +	// +required
    +	RuleStatus RuleStatus `json:"ruleStatus,omitempty"`
    +
    +	// taintStatus reflects the observed state of the rule's specified taint on the Node (Present/Absent).
    +	//
    +	// +required
    +	TaintStatus TaintStatus `json:"taintStatus,omitempty"`
    +
    +	// reason contains a concise, machine-readable string detailing the primary outcome.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=256
    +	Reason string `json:"reason,omitempty"`
    +
    +	// message is a comprehensive, human-readable explanation providing further context.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=10240

    is it intentionally 10K?

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:14 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100
    +	Rules []RuleEvaluation `json:"rules,omitempty"`
    +}
    +
    +// RuleRef identifies a NodeReadinessRule by its name and UID.
    +// Bundling both fields into a single struct makes the identity unit explicit and
    +// mirrors the pattern used by metav1.OwnerReference.
    +type RuleRef struct {
    +	// name is the name of the NodeReadinessRule.
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	Name string `json:"name,omitempty"`
    +
    +	// uid is the UID of the NodeReadinessRule.
    +	// If the rule is deleted and recreated with the same name, the UID will differ,
    +	// allowing the controller to detect and replace stale evaluation entries.
    +	//
    +	// +required
    +	UID types.UID `json:"uid,omitempty"`
    +}
    +
    +// RuleEvaluation defines the outcome of evaluating a single NodeReadinessRule against this Node.
    +type RuleEvaluation struct {
    +	// ruleRef identifies the NodeReadinessRule this evaluation applies to.
    +	// It bundles the rule's name (human-readable) and UID (tamper-proof identity)
    +	// so that delete-and-recreate of a same-named rule is always detectable.
    +	//
    +	// +required
    +	RuleRef RuleRef `json:"ruleRef,omitempty,omitzero"`
    +
    +	// ruleStatus indicates the overall outcome of the rule's criteria against the Node.
    +	//
    +	// +required
    +	RuleStatus RuleStatus `json:"ruleStatus,omitempty"`
    +
    +	// taintStatus reflects the observed state of the rule's specified taint on the Node (Present/Absent).
    +	//
    +	// +required
    +	TaintStatus TaintStatus `json:"taintStatus,omitempty"`
    +
    +	// reason contains a concise, machine-readable string detailing the primary outcome.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=256
    +	Reason string `json:"reason,omitempty"`
    +
    +	// message is a comprehensive, human-readable explanation providing further context.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=10240

    I was surprised at this thinking why should they be this long, but looks like k8s api gives 32k for Message and 1024! for Reason as well: https://github.com/kubernetes/apimachinery/blob/50d9b4a672b474db2e0bf61c968d87465b55eb56/pkg/apis/meta/v1/types.go#L1702. so ours is fine!

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:16 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100
    +	Rules []RuleEvaluation `json:"rules,omitempty"`
    +}
    +
    +// RuleRef identifies a NodeReadinessRule by its name and UID.
    +// Bundling both fields into a single struct makes the identity unit explicit and
    +// mirrors the pattern used by metav1.OwnerReference.
    +type RuleRef struct {
    +	// name is the name of the NodeReadinessRule.
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	Name string `json:"name,omitempty"`
    +
    +	// uid is the UID of the NodeReadinessRule.
    +	// If the rule is deleted and recreated with the same name, the UID will differ,
    +	// allowing the controller to detect and replace stale evaluation entries.
    +	//
    +	// +required
    +	UID types.UID `json:"uid,omitempty"`
    +}
    +
    +// RuleEvaluation defines the outcome of evaluating a single NodeReadinessRule against this Node.
    +type RuleEvaluation struct {
    +	// ruleRef identifies the NodeReadinessRule this evaluation applies to.
    +	// It bundles the rule's name (human-readable) and UID (tamper-proof identity)
    +	// so that delete-and-recreate of a same-named rule is always detectable.
    +	//
    +	// +required
    +	RuleRef RuleRef `json:"ruleRef,omitempty,omitzero"`
    +
    +	// ruleStatus indicates the overall outcome of the rule's criteria against the Node.
    +	//
    +	// +required
    +	RuleStatus RuleStatus `json:"ruleStatus,omitempty"`
    +
    +	// taintStatus reflects the observed state of the rule's specified taint on the Node (Present/Absent).
    +	//
    +	// +required
    +	TaintStatus TaintStatus `json:"taintStatus,omitempty"`
    +
    +	// reason contains a concise, machine-readable string detailing the primary outcome.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=256
    +	Reason string `json:"reason,omitempty"`
    +
    +	// message is a comprehensive, human-readable explanation providing further context.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=10240
    +	Message string `json:"message,omitempty"`
    +
    +	// readinessConditions provides a detailed breakdown of each condition evaluation
    +	// for this Node. This allows for granular debugging of which specific criteria passed/failed.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=32
    +	ReadinessConditions []ConditionEvaluationResult `json:"readinessConditions,omitempty"`
    +
    +	// lastEvaluationTime records the exact moment the controller most recently assessed this rule.
    +	//
    +	// +required
    +	LastEvaluationTime metav1.Time `json:"lastEvaluationTime,omitempty,omitzero"`
    +
    +	// firstEvaluatedAt is the time the rule was first assessed against this node.
    +	//
    +	// +optional
    +	FirstEvaluatedAt *metav1.Time `json:"firstEvaluatedAt,omitempty"`
    +
    +	// taintObservedAt is the time NRC first observed the taint present on the node,
    +	// regardless of whether NRC applied it or it was pre-existing (e.g. via --register-with-taints).
    +	// This marks the beginning of the node being blocked by this rule and is the correct
    +	// start time for computing time-to-unblock SLIs.
    +	//
    +	// +optional
    +	TaintObservedAt *metav1.Time `json:"taintObservedAt,omitempty"`
    +
    +	// taintAddedAt is the time NRC itself applied the taint to the node.
    +	// This field is nil when the taint was pre-existing and NRC adopted it rather than creating it.
    +	// Use taintObservedAt for "how long has the node been blocked"; use this field to measure
    +	// NRC's own apply latency (taintAddedAt - firstEvaluatedAt).
    +	//
    +	// +optional
    +	TaintAddedAt *metav1.Time `json:"taintAddedAt,omitempty"`

    do we update this in continuous when Taint is reapplied?

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:16 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100
    +	Rules []RuleEvaluation `json:"rules,omitempty"`
    +}
    +
    +// RuleRef identifies a NodeReadinessRule by its name and UID.
    +// Bundling both fields into a single struct makes the identity unit explicit and
    +// mirrors the pattern used by metav1.OwnerReference.
    +type RuleRef struct {
    +	// name is the name of the NodeReadinessRule.
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	Name string `json:"name,omitempty"`
    +
    +	// uid is the UID of the NodeReadinessRule.
    +	// If the rule is deleted and recreated with the same name, the UID will differ,
    +	// allowing the controller to detect and replace stale evaluation entries.
    +	//
    +	// +required
    +	UID types.UID `json:"uid,omitempty"`
    +}
    +
    +// RuleEvaluation defines the outcome of evaluating a single NodeReadinessRule against this Node.
    +type RuleEvaluation struct {
    +	// ruleRef identifies the NodeReadinessRule this evaluation applies to.
    +	// It bundles the rule's name (human-readable) and UID (tamper-proof identity)
    +	// so that delete-and-recreate of a same-named rule is always detectable.
    +	//
    +	// +required
    +	RuleRef RuleRef `json:"ruleRef,omitempty,omitzero"`
    +
    +	// ruleStatus indicates the overall outcome of the rule's criteria against the Node.
    +	//
    +	// +required
    +	RuleStatus RuleStatus `json:"ruleStatus,omitempty"`
    +
    +	// taintStatus reflects the observed state of the rule's specified taint on the Node (Present/Absent).
    +	//
    +	// +required
    +	TaintStatus TaintStatus `json:"taintStatus,omitempty"`
    +
    +	// reason contains a concise, machine-readable string detailing the primary outcome.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=256
    +	Reason string `json:"reason,omitempty"`
    +
    +	// message is a comprehensive, human-readable explanation providing further context.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=10240
    +	Message string `json:"message,omitempty"`
    +
    +	// readinessConditions provides a detailed breakdown of each condition evaluation
    +	// for this Node. This allows for granular debugging of which specific criteria passed/failed.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=32
    +	ReadinessConditions []ConditionEvaluationResult `json:"readinessConditions,omitempty"`
    +
    +	// lastEvaluationTime records the exact moment the controller most recently assessed this rule.
    +	//
    +	// +required
    +	LastEvaluationTime metav1.Time `json:"lastEvaluationTime,omitempty,omitzero"`
    +
    +	// firstEvaluatedAt is the time the rule was first assessed against this node.
    +	//
    +	// +optional
    +	FirstEvaluatedAt *metav1.Time `json:"firstEvaluatedAt,omitempty"`
    +
    +	// taintObservedAt is the time NRC first observed the taint present on the node,
    +	// regardless of whether NRC applied it or it was pre-existing (e.g. via --register-with-taints).
    +	// This marks the beginning of the node being blocked by this rule and is the correct
    +	// start time for computing time-to-unblock SLIs.
    +	//
    +	// +optional
    +	TaintObservedAt *metav1.Time `json:"taintObservedAt,omitempty"`
    +
    +	// taintAddedAt is the time NRC itself applied the taint to the node.
    +	// This field is nil when the taint was pre-existing and NRC adopted it rather than creating it.
    +	// Use taintObservedAt for "how long has the node been blocked"; use this field to measure
    +	// NRC's own apply latency (taintAddedAt - firstEvaluatedAt).
    +	//
    +	// +optional
    +	TaintAddedAt *metav1.Time `json:"taintAddedAt,omitempty"`

    or should we split into FirstAppliedAt and CurrentTaintAppliedAt?

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:20 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100
    +	Rules []RuleEvaluation `json:"rules,omitempty"`
    +}
    +
    +// RuleRef identifies a NodeReadinessRule by its name and UID.
    +// Bundling both fields into a single struct makes the identity unit explicit and
    +// mirrors the pattern used by metav1.OwnerReference.
    +type RuleRef struct {
    +	// name is the name of the NodeReadinessRule.
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	Name string `json:"name,omitempty"`
    +
    +	// uid is the UID of the NodeReadinessRule.
    +	// If the rule is deleted and recreated with the same name, the UID will differ,
    +	// allowing the controller to detect and replace stale evaluation entries.
    +	//
    +	// +required
    +	UID types.UID `json:"uid,omitempty"`
    +}
    +
    +// RuleEvaluation defines the outcome of evaluating a single NodeReadinessRule against this Node.
    +type RuleEvaluation struct {
    +	// ruleRef identifies the NodeReadinessRule this evaluation applies to.
    +	// It bundles the rule's name (human-readable) and UID (tamper-proof identity)
    +	// so that delete-and-recreate of a same-named rule is always detectable.
    +	//
    +	// +required
    +	RuleRef RuleRef `json:"ruleRef,omitempty,omitzero"`
    +
    +	// ruleStatus indicates the overall outcome of the rule's criteria against the Node.
    +	//
    +	// +required
    +	RuleStatus RuleStatus `json:"ruleStatus,omitempty"`
    +
    +	// taintStatus reflects the observed state of the rule's specified taint on the Node (Present/Absent).
    +	//
    +	// +required
    +	TaintStatus TaintStatus `json:"taintStatus,omitempty"`
    +
    +	// reason contains a concise, machine-readable string detailing the primary outcome.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=256
    +	Reason string `json:"reason,omitempty"`
    +
    +	// message is a comprehensive, human-readable explanation providing further context.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=10240
    +	Message string `json:"message,omitempty"`
    +
    +	// readinessConditions provides a detailed breakdown of each condition evaluation
    +	// for this Node. This allows for granular debugging of which specific criteria passed/failed.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=32
    +	ReadinessConditions []ConditionEvaluationResult `json:"readinessConditions,omitempty"`
    +
    +	// lastEvaluationTime records the exact moment the controller most recently assessed this rule.
    +	//
    +	// +required
    +	LastEvaluationTime metav1.Time `json:"lastEvaluationTime,omitempty,omitzero"`
    +
    +	// firstEvaluatedAt is the time the rule was first assessed against this node.
    +	//
    +	// +optional
    +	FirstEvaluatedAt *metav1.Time `json:"firstEvaluatedAt,omitempty"`

    nit: is this for observing possible rule-reconciliation delay on the node? I think the other TaintAt times are also set at the first rule-reconciliation times. but I think I'm okay to keep this as it may bring some additional insights on rule's actions later.

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:24 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100
    +	Rules []RuleEvaluation `json:"rules,omitempty"`
    +}
    +
    +// RuleRef identifies a NodeReadinessRule by its name and UID.
    +// Bundling both fields into a single struct makes the identity unit explicit and
    +// mirrors the pattern used by metav1.OwnerReference.
    +type RuleRef struct {
    +	// name is the name of the NodeReadinessRule.
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	Name string `json:"name,omitempty"`
    +
    +	// uid is the UID of the NodeReadinessRule.
    +	// If the rule is deleted and recreated with the same name, the UID will differ,
    +	// allowing the controller to detect and replace stale evaluation entries.
    +	//
    +	// +required
    +	UID types.UID `json:"uid,omitempty"`
    +}
    +
    +// RuleEvaluation defines the outcome of evaluating a single NodeReadinessRule against this Node.
    +type RuleEvaluation struct {
    +	// ruleRef identifies the NodeReadinessRule this evaluation applies to.
    +	// It bundles the rule's name (human-readable) and UID (tamper-proof identity)
    +	// so that delete-and-recreate of a same-named rule is always detectable.
    +	//
    +	// +required
    +	RuleRef RuleRef `json:"ruleRef,omitempty,omitzero"`
    +
    +	// ruleStatus indicates the overall outcome of the rule's criteria against the Node.
    +	//
    +	// +required
    +	RuleStatus RuleStatus `json:"ruleStatus,omitempty"`
    +
    +	// taintStatus reflects the observed state of the rule's specified taint on the Node (Present/Absent).
    +	//
    +	// +required
    +	TaintStatus TaintStatus `json:"taintStatus,omitempty"`
    +
    +	// reason contains a concise, machine-readable string detailing the primary outcome.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=256
    +	Reason string `json:"reason,omitempty"`
    +
    +	// message is a comprehensive, human-readable explanation providing further context.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=10240
    +	Message string `json:"message,omitempty"`
    +
    +	// readinessConditions provides a detailed breakdown of each condition evaluation
    +	// for this Node. This allows for granular debugging of which specific criteria passed/failed.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=32
    +	ReadinessConditions []ConditionEvaluationResult `json:"readinessConditions,omitempty"`
    +
    +	// lastEvaluationTime records the exact moment the controller most recently assessed this rule.
    +	//
    +	// +required
    +	LastEvaluationTime metav1.Time `json:"lastEvaluationTime,omitempty,omitzero"`

    This means we are updating all the matching nodes' RuleEvals, irrespective of whether they are satisfied.

    Rule-reconciliations should be less frequent - only on rule modifications - so this seems fine, and 'freshness' details of evaluations maybe helpful.

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:32 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic
    +	// +kubebuilder:validation:MaxItems=100
    +	Rules []RuleEvaluation `json:"rules,omitempty"`
    +}
    +
    +// RuleRef identifies a NodeReadinessRule by its name and UID.
    +// Bundling both fields into a single struct makes the identity unit explicit and
    +// mirrors the pattern used by metav1.OwnerReference.
    +type RuleRef struct {
    +	// name is the name of the NodeReadinessRule.
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	Name string `json:"name,omitempty"`
    +
    +	// uid is the UID of the NodeReadinessRule.
    +	// If the rule is deleted and recreated with the same name, the UID will differ,
    +	// allowing the controller to detect and replace stale evaluation entries.
    +	//
    +	// +required
    +	UID types.UID `json:"uid,omitempty"`
    +}
    +
    +// RuleEvaluation defines the outcome of evaluating a single NodeReadinessRule against this Node.
    +type RuleEvaluation struct {
    +	// ruleRef identifies the NodeReadinessRule this evaluation applies to.
    +	// It bundles the rule's name (human-readable) and UID (tamper-proof identity)
    +	// so that delete-and-recreate of a same-named rule is always detectable.
    +	//
    +	// +required
    +	RuleRef RuleRef `json:"ruleRef,omitempty,omitzero"`
    +
    +	// ruleStatus indicates the overall outcome of the rule's criteria against the Node.
    +	//
    +	// +required
    +	RuleStatus RuleStatus `json:"ruleStatus,omitempty"`
    +
    +	// taintStatus reflects the observed state of the rule's specified taint on the Node (Present/Absent).
    +	//
    +	// +required
    +	TaintStatus TaintStatus `json:"taintStatus,omitempty"`
    +
    +	// reason contains a concise, machine-readable string detailing the primary outcome.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=256
    +	Reason string `json:"reason,omitempty"`
    +
    +	// message is a comprehensive, human-readable explanation providing further context.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=10240
    +	Message string `json:"message,omitempty"`
    +
    +	// readinessConditions provides a detailed breakdown of each condition evaluation
    +	// for this Node. This allows for granular debugging of which specific criteria passed/failed.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=32
    +	ReadinessConditions []ConditionEvaluationResult `json:"readinessConditions,omitempty"`
    +
    +	// lastEvaluationTime records the exact moment the controller most recently assessed this rule.
    +	//
    +	// +required
    +	LastEvaluationTime metav1.Time `json:"lastEvaluationTime,omitempty,omitzero"`
    +
    +	// firstEvaluatedAt is the time the rule was first assessed against this node.
    +	//
    +	// +optional
    +	FirstEvaluatedAt *metav1.Time `json:"firstEvaluatedAt,omitempty"`
    +
    +	// taintObservedAt is the time NRC first observed the taint present on the node,
    +	// regardless of whether NRC applied it or it was pre-existing (e.g. via --register-with-taints).
    +	// This marks the beginning of the node being blocked by this rule and is the correct
    +	// start time for computing time-to-unblock SLIs.
    +	//
    +	// +optional
    +	TaintObservedAt *metav1.Time `json:"taintObservedAt,omitempty"`
    +
    +	// taintAddedAt is the time NRC itself applied the taint to the node.
    +	// This field is nil when the taint was pre-existing and NRC adopted it rather than creating it.
    +	// Use taintObservedAt for "how long has the node been blocked"; use this field to measure
    +	// NRC's own apply latency (taintAddedAt - firstEvaluatedAt).
    +	//
    +	// +optional
    +	TaintAddedAt *metav1.Time `json:"taintAddedAt,omitempty"`
    +
    +	// taintRemovedAt is the time the controller successfully removed the taint
    +	// after the node satisfied all conditions.
    +	//
    +	// +optional
    +	TaintRemovedAt *metav1.Time `json:"taintRemovedAt,omitempty"`
    +}
    +
    +// EvaluationSummary aggregates the results to provide a high-level overview.
    +// +kubebuilder:validation:MinProperties=1
    +type EvaluationSummary struct {
    +	// matchedRules is the total number of rules currently matching this node.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:Minimum=0
    +	MatchedRules *int32 `json:"matchedRules,omitempty"`
    +
    +	// activeTaints is the total number of taints successfully managed by the controller.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:Minimum=0
    +	ActiveTaints *int32 `json:"activeTaints,omitempty"`
    +
    +	// errors is the total number of rules that failed to evaluate properly.
    +	//
    +	// +optional
    +	// +kubebuilder:validation:Minimum=0
    +	Errors *int32 `json:"errors,omitempty"`
    +}
    +
    +// +kubebuilder:object:root=true
    +// +kubebuilder:subresource:status
    +// +kubebuilder:resource:scope=Cluster,shortName=nre
    +// +kubebuilder:printcolumn:name="Node",type=string,JSONPath=`.spec.nodeName`,description="The name of the target Node."
    +// +kubebuilder:selectablefield:JSONPath=`.spec.nodeName`
    +// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`,description="The overall readiness evaluation state of the node."

    ah, now I see where do you see these enums for state.

    could we use Status=(?Condition==Ready).status?

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:36 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.
    +	// - "Ready": indicates whether the node has satisfied all rules and has zero taints applied.
    +	//
    +	// +optional
    +	// +listType=map
    +	// +listMapKey=type
    +	// +kubebuilder:validation:MaxItems=8
    +	Conditions []metav1.Condition `json:"conditions,omitempty"`
    +
    +	// state indicates the overall readiness state of the node based on all applicable rules.
    +	// It acts as a top-level health indicator for this node's readiness evaluation.
    +	//
    +	// +optional
    +	State NodeEvaluationState `json:"state,omitempty"`
    +
    +	// summary provides a quick, aggregated overview of the rules applied to this node.
    +	//
    +	// +optional
    +	Summary EvaluationSummary `json:"summary,omitempty,omitzero"`
    +
    +	// rules contains the evaluation outcomes for all rules applicable to this node.
    +	// The slice is owned and fully replaced by the controller on each reconcile (listType=atomic).
    +	//
    +	// +optional
    +	// +listType=atomic

    we would need this for multiple rule-workers working in parallel. and ref is not compatible with map, so it'd be good to consider flattening the rule references here.

    ajaysundark ajaysundark commented on code on Aug 30, 2026 06:57 UTC
    Code Review
    internal/controller/nodereadinessevaluation_controller.go:1
    @@ -0,0 +1,395 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package controller
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	corev1 "k8s.io/api/core/v1"
    +	apierrors "k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/runtime"
    +	"k8s.io/apimachinery/pkg/types"
    +	ctrl "sigs.k8s.io/controller-runtime"
    +	"sigs.k8s.io/controller-runtime/pkg/builder"
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
    +	"sigs.k8s.io/controller-runtime/pkg/event"
    +	"sigs.k8s.io/controller-runtime/pkg/handler"
    +	"sigs.k8s.io/controller-runtime/pkg/predicate"
    +	"sigs.k8s.io/controller-runtime/pkg/reconcile"
    +
    +	readinessv1alpha1 "sigs.k8s.io/node-readiness-controller/api/v1alpha1"
    +)
    +
    +// NodeReadinessEvaluationReconciler is an independent reconciler that maintains
    +// one NodeReadinessEvaluation object per Node. It watches Nodes and
    +// NodeReadinessRules and re-evaluates the full rule set for the affected node
    +// on every relevant change. It shares the rule cache owned by
    +// RuleReadinessController but never writes to Node taints or NRR status —
    +// those remain the sole responsibility of NodeReconciler / RuleReconciler.
    +type NodeReadinessEvaluationReconciler struct {
    +	client.Client
    +	Scheme     *runtime.Scheme
    +	Controller *RuleReadinessController
    +}
    +
    +// SetupWithManager wires the reconciler to watch:
    +//   - Node objects (conditions, taints, labels)
    +//   - NodeReadinessRule objects (enqueues all nodes matching the changed rule)
    +func (r *NodeReadinessEvaluationReconciler) SetupWithManager(mgr ctrl.Manager) error {

    hmm. I maybe wrong about the API scale. but my primary concern is that NRE suppose to be a 'record' of what the controller enforced at node but a second reconciler recomputes the decision by further observations. This could bring other race and complexity of state handling.

    For example, how do we distinguish even between kubelet added it vs another reconciler added it, when NRE is computed separately in its reconciler?

    blast radius and separate of concern

    I understand your concern on the implementation risks injecting this detail throughout the controller code. I was imagining #343 could simplify it for the rule, and maybe eventually #389 when we would have to handle the node updates all at just one place.

    Karthik-K-N Karthik-K-N commented on code on Aug 31, 2026 05:21 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.
    +// +kubebuilder:validation:Enum=Ready;NotReady;Pending
    +type NodeEvaluationState string
    +
    +const (
    +	// NodeEvaluationStateReady indicates the node has successfully satisfied all applicable rules.
    +	NodeEvaluationStateReady NodeEvaluationState = "Ready"
    +
    +	// NodeEvaluationStateNotReady indicates one or more applicable rules are currently not satisfied.
    +	NodeEvaluationStateNotReady NodeEvaluationState = "NotReady"
    +
    +	// NodeEvaluationStatePending indicates the node is currently being evaluated or state is unknown.
    +	NodeEvaluationStatePending NodeEvaluationState = "Pending"
    +)
    +
    +// RuleStatus defines the result of evaluating a NodeReadinessRule's criteria against a Node.
    +// +kubebuilder:validation:Enum=Satisfied;Unsatisfied;Error
    +type RuleStatus string
    +
    +const (
    +	// RuleStatusSatisfied indicates that the Node successfully met all conditions
    +	// defined in the NodeReadinessRule. The controller will ensure the corresponding
    +	// taint is removed so the node is unblocked.
    +	RuleStatusSatisfied RuleStatus = "Satisfied"
    +
    +	// RuleStatusUnsatisfied indicates that one or more conditions defined in the
    +	// NodeReadinessRule were not met. The controller will ensure the corresponding
    +	// taint remains present to block scheduling.
    +	RuleStatusUnsatisfied RuleStatus = "Unsatisfied"
    +
    +	// RuleStatusError indicates that a programmatic or configuration error occurred
    +	// during the evaluation process (e.g., an invalid or unparseable NodeSelector).
    +	// The controller cannot safely determine if the taint should be present or absent.
    +	RuleStatusError RuleStatus = "Error"
    +)
    +
    +// NodeReadinessEvaluationSpec defines the desired state of NodeReadinessEvaluation.
    +type NodeReadinessEvaluationSpec struct {
    +	// nodeName specifies the exact name of the target Kubernetes Node.
    +	// This object establishes a strict 1:1 relationship with the specified node,
    +	// acting as the single source of truth for all rules and statuses applied to it.
    +	// Because it binds this resource to a specific physical or virtual machine, it cannot be changed once set.
    +	//
    +	// The validation constraints enforce standard Kubernetes resource naming
    +	// (RFC 1123 DNS Subdomain format), as defined in upstream apimachinery:
    +	// https://github.com/kubernetes/apimachinery/blob/master/pkg/util/validation/validation.go#L198
    +	//
    +	// +required
    +	// +kubebuilder:validation:MinLength=1
    +	// +kubebuilder:validation:MaxLength=253
    +	// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
    +	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="nodeName is immutable and cannot be changed once set"
    +	NodeName string `json:"nodeName,omitempty"`
    +}
    +
    +// NodeReadinessEvaluationStatus defines the observed state of NodeReadinessEvaluation.
    +// +kubebuilder:validation:MinProperties=1
    +type NodeReadinessEvaluationStatus struct {
    +	// conditions represent the latest available observations of the node's readiness evaluation state.
    +	// Known condition types are:
    +	// - "Evaluated": indicates whether the controller successfully evaluated all rules without errors.

    Yes Correct, What I thought is, when the Ready/Available is False, User can check the status of Evaluated
    1. when Its True that means the Rule is successfully evaluated but its not satisfied on the Node.
    2. when its False it can be Inprogress means the Rule is currently being reconciled
    3. when its False it can be error means, there can be any intermittent error like api error or selector error

    Karthik-K-N Karthik-K-N commented on code on Aug 31, 2026 05:29 UTC
    Code Review
    api/v1alpha1/nodereadinessevaluation_types.go:1
    @@ -0,0 +1,281 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package v1alpha1
    +
    +import (
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	"k8s.io/apimachinery/pkg/types"
    +)
    +
    +// NodeEvaluationState indicates the overall readiness state of the node based on all rules.

    It feels redundant but having it will enhance the user experience
    1. Helps in printing the result when queried the NRE using kubectl as we can't easily print the conditions

    kubectl get nre
    NAME             NODE             STATE       AGE
    nre-node-worker1 node-worker1     Available   5m
    nre-node-worker2 node-worker2     NotAvailable 2m
    

    2. Currently its being markes as selectable field so we can do something like this
    kubectl get nre --field-selector status.state=NotAvailable
    

    Apart from this there is no other intention we should be good to drop as well.

    Reviewers
    Assignees
    Karthik-K-N Karthik-K-N
    Labels
    risk: low confidence: 90.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 78.5% (HIGH) · Higher = larger blast radius
    78.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 90.8% · Lower = rushed or shallow review
    90.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.3% · Safe to merge
    7.3%