Put the dra-target label on the nodes a DRA Module selects #1351
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1351"
general
weight: 0.35
yevgeny-shnaidman
Second piece out of #1329. It puts the
dra-targetlabel 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, andkubectl drainwill not evict it: it refuses to run without--ignore-daemonsetsand skips the Pod with it. The only thing that takes the Pod away is its nodeSelector no longer matching. Today that selector asks forkmm-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 adevice-plugin-targetlabel; the DRA reconciler never got the counterpart.This adds the label and requires it in the node selector of DRA DaemonSets.
handleDRATargetLabelsputs it on every schedulable node the Module selects, which is the same shape ashandleDevicePluginTargetLabels, 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.tolerationsalone 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 carryingnot-readyandunreachableatNoExecute, anddisk-pressure,memory-pressure,pid-pressureandunschedulableatNoSchedule.The
unschedulableone 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
UpdateLabelssends 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
moduleUpdateDRAStatusgivesGetNumTargetedNodesthe Module's tolerations alone, so a node under pressure that still runs the driver Pod counts towardAvailableNumberbut notDesiredNumber.A Module with no
moduleLoaderhas its nodes labelled too, the same as for the device plugin.setDRAAsDesiredstill replaces the node selector withmod.Spec.Selectorin 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.
handleDRAreads the live object's entry for the label beforesetDRAAsDesiredruns 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 amoduleLoadera 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 nospec.draas well, and each of those passes makes the twoDeleteAllOfcalls 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.mdsays 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 nomoduleLoaderdoes not select on it, and lists nodes among what that loop watches.What is deliberately not here
IsDRATargetNodeLabel,GetAllNodesByLabelKeyandUpdateLabelsWithOptimisticLockfrom #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;nodesUsingDRADriveris an unexported method, so it would also failunuseduntil the claims arrive.No RBAC change:
nodesalready carriesget,list,watchandpatchfrom the Module reconciler, and theresourceclaimsandeventsrules #1329 adds belong with the claims.Testing
DRAReconciler_handleDRATargetLabelsdrives the realIsNodeSchedulablerather 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 nomoduleLoader, 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
setDRAAsDesiredspec now also checks the label in the node selector, the way #1274 did for the device plugin.DRAReconciler_handleDRAhas specs for a DaemonSet that already exists, with and without the label, and one for a Module with nomoduleLoader, whose own selector must not pick up the label.I also ran it on kind v1.35.0 with a Module carrying both
moduleLoaderanddra, which is the shapeci/module-kmm-ci-dra.yamluses and the one whose DaemonSet selects on the label. On a fresh install the DaemonSet comes up withnodeSelector: {"...imod.ready": "", "...imod.dra-target": ""}and the node carries the label. For the upgrade case, a manager built frommainfirst creates the DaemonSet withnodeSelector: {"...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
draand nomoduleLoaderon 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'snodeSelectorequal 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
moduleLoaderskip back reddens everyhandleDRATargetLabelsspec except the one with no DRA spec. The watch is the exception, since there is noSetupWithManagertest in this repo to extend, so the kind runs above are what stand behind it.make lint,make generateandgo test ./internal/...are clean, andmake manifestsleavesconfig/unchanged.Part of #1328.