← Back to Pull requests

Put the dra-target label on the nodes a DRA Module selects #1351

Closed
unknown closed this pull request without merging on Sep 29, 2026 12:50 UTC
View on GitHub
unknown unknown commented on Sep 09, 2026 13:30 UTC
Author

Second piece out of #1329. It puts the dra-target label in place and leaves everything that acts on it to the piece after.

A DaemonSet Pod carries an automatic toleration for node.kubernetes.io/unschedulable, so cordoning a node does nothing to the DRA driver Pod on its own, and kubectl drain will not evict it: it refuses to run without --ignore-daemonsets and skips the Pod with it. The only thing that takes the Pod away is its nodeSelector no longer matching. Today that selector asks for kmm-ready, which stays until the unloader succeeds, and the unloader cannot succeed while the driver still holds the kernel module. #1274 solved the same problem for the device plugin with a device-plugin-target label; the DRA reconciler never got the counterpart.

This adds the label and requires it in the node selector of DRA DaemonSets. handleDRATargetLabels puts it on every schedulable node the Module selects, which is the same shape as handleDevicePluginTargetLabels, minus the removal and with the two differences below.

Which nodes count as schedulable

The check gets the Module's tolerations plus KMM's internal ones. The DaemonSet controller adds the disk, memory and PID pressure tolerations to the Pods it creates whether or not the template carries them, so judging on spec.tolerations alone would keep the label off a node the driver can run on perfectly well. On kind v1.35.0, a DaemonSet whose template declares no tolerations produces Pods carrying not-ready and unreachable at NoExecute, and disk-pressure, memory-pressure, pid-pressure and unschedulable at NoSchedule.

The unschedulable one is deliberately left out of the decision. Reacting to a cordon is what this label is for, so a cordoned node has to fall out of it.

A node that already carries the label with the empty value is skipped, since UpdateLabels sends a PATCH even when nothing changes. A node whose label carries something other than the empty string is written again. The DaemonSet selector matches on that exact value, so a key holding anything else leaves the node unmatched, and skipping on the key alone would leave nothing to correct it. The device plugin's equivalent writes unconditionally and so has no such state to get stuck in.

The status count uses the same tolerations. On master moduleUpdateDRAStatus gives GetNumTargetedNodes the Module's tolerations alone, so a node under pressure that still runs the driver Pod counts toward AvailableNumber but not DesiredNumber.

A Module with no moduleLoader has its nodes labelled too, the same as for the device plugin. setDRAAsDesired still replaces the node selector with mod.Spec.Selector in that case, so its DaemonSet does not read the label.

Why nobody upgrading sees anything move

Requiring the label narrows what a DaemonSet selects, so putting it on one that already exists would drop its Pods from every node that does not have it. handleDRA reads the live object's entry for the label before setDRAAsDesired runs and puts it back afterwards, so an existing DaemonSet keeps what it had and only a newly created one starts out selecting on the label. Nothing removes the label either, so for a Module with a moduleLoader a node that stops being selected keeps its driver Pod, exactly as it does today.

That is also why this does not fix #1328 on its own. The removal, the ResourceClaim retention that decides when removal is safe, and the migration of DaemonSets that already exist all go together in the next piece, since none of them is safe without the others.

Why it watches nodes

The label is read off a node's own labels and taints, and none of the reconciler's other watches see those change; #1328 names the missing Node watch for the same reason. Measured on kind v1.35.0 by counting this reconciler's passes across a node label change that left the Module and its DaemonSet alone: without the watch it did not run (5 before, 5 after) while the Module reconciler did; with the watch it ran (5 to 6). In practice the label still lands most of the time, because the same event usually changes the Module reconciler's node count and its status write brings this one round. The watch is what stops that being a dependency.

The predicate is the Module reconciler's, which fires on labels as well as taints, since both go into the decision. It also uses the shared FindModulesForNode, so a node event wakes this reconciler for Modules with no spec.dra as well, and each of those passes makes the two DeleteAllOf calls of the cleanup path. The device plugin reconciler wakes the same way, and a DRA-only mapper did not seem worth a second copy. Say if you would rather have one.

Docs

The DRA section of docs/mkdocs/developer/reconciliation_loops.md says the driver DaemonSet targets nodes where the kernel module is loaded, which is no longer the whole story. It now names the label, says the reconciler adds it and does not remove it, notes that the DaemonSet of a Module with no moduleLoader does not select on it, and lists nodes among what that loop watches.

What is deliberately not here

IsDRATargetNodeLabel, GetAllNodesByLabelKey and UpdateLabelsWithOptimisticLock from #1329 are not in this piece. They serve the removal path, and there is nothing here to call them, so they would land as code a reviewer has to judge without the thing that uses it. The ResourceClaim index is out for the same reason, which corrects what I said on the 8th about putting it in the first piece; nodesUsingDRADriver is an unexported method, so it would also fail unused until the claims arrive.

No RBAC change: nodes already carries get, list, watch and patch from the Module reconciler, and the resourceclaims and events rules #1329 adds belong with the claims.

Testing

DRAReconciler_handleDRATargetLabels drives the real IsNodeSchedulable rather than a mocked answer, so the set of tolerations it is handed is actually under test: a node under memory pressure gets the label, a cordoned one does not, and one whose taint the Module tolerates does. Its fixture has no moduleLoader, so those specs also cover the label going on without one. There are specs for the Module's own tolerations slice being left alone, a label value that is not empty, a node that already has the label, a listing failure, and one node failing while the rest go on.

The existing setDRAAsDesired spec now also checks the label in the node selector, the way #1274 did for the device plugin. DRAReconciler_handleDRA has specs for a DaemonSet that already exists, with and without the label, and one for a Module with no moduleLoader, whose own selector must not pick up the label.

I also ran it on kind v1.35.0 with a Module carrying both moduleLoader and dra, which is the shape ci/module-kmm-ci-dra.yaml uses and the one whose DaemonSet selects on the label. On a fresh install the DaemonSet comes up with nodeSelector: {"...imod.ready": "", "...imod.dra-target": ""} and the node carries the label. For the upgrade case, a manager built from main first creates the DaemonSet with nodeSelector: {"...imod.ready": ""}; restarting on this branch leaves that DaemonSet alone, same name and same selector, and puts the node label beside it. One DaemonSet throughout, so the label write does not come back round and produce a second one.

After the change asked for in review I also ran a Module with dra and no moduleLoader on kind v1.35.8, first with a manager built from the previous head and then with this one. The previous build never labelled the node. This one labelled it with a single PATCH, left the DaemonSet's nodeSelector equal to the Module's selector and the Module's own selector untouched, and then settled: two passes and no further node PATCH over the next 100 seconds. Cordoning the node kept both the label and the driver Pod.

Reverting any of these reddens a spec by name: the label leaving the selector, the schedulability check, the carry-over that keeps an existing DaemonSet where it is (two specs), the check that keeps the Module's own selector untouched, the internal tolerations, the slice that must not be written through, the label value being rewritten, and the status count on a node under memory pressure. Putting the moduleLoader skip back reddens every handleDRATargetLabels spec except the one with no DRA spec. The watch is the exception, since there is no SetupWithManager test in this repo to extend, so the kind runs above are what stand behind it. make lint, make generate and go test ./internal/... are clean, and make manifests leaves config/ unchanged.

Part of #1328.

Diff: 650 lines (+487 / -163) across 8 files Reviewer: yevgeny-shnaidman Review duration: 28759m
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
0.52
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
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.388
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1351"
general weight: 0.35
Assignees
Unassigned
Labels
risk: low confidence: 60.5% 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: 52% (MEDIUM) · Higher = larger blast radius
52%
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: 60.5% · Lower = rushed or shallow review
60.5%
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: 20.5% · Safe to merge
20.5%