Fix nri lifecycle #426
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 #426"
general
weight: 0.35
npinaeva
What type of PR is this?
/kind bug
What this PR does / why we need it:
A pod must not get a sandbox while the container runtime does not have the DRANET NRI plugin. The runtime then creates the sandbox without the network interfaces, and nothing repairs it later. https://github.com/kubernetes-sigs/dranet/issues/424#issuecomment-7023862177 lists the ways in which this happened. This PR closes the ones that DRANET can close.
NodePrepareResourcesagain for a claim that is already prepared. NowStartconnects the NRI plugin first and starts the DRA plugin after that.PrepareResourceClaimsrejects non-empty calls while the NRI plugin is not connected, so the kubelet does not prepare a new claim in that time./healthzis the logical AND of two checks, and/healthz/draand/healthz/nrireport each one, in the style of the apiserver (?verbose,?exclude=). The readiness probe now fails while the NRI plugin is not connected.driver.Startis split intodriver.Newand(*NetworkDriver).Start, socmd/dranetregisters the checks before the driver starts.The state of the NRI connection is one variable,
nriConnected. Only the loop that runs the stub writes it: it sets it whenStartof the stub returns and clears it whenWaitreturns. The NRI hooks do not write it, because the close callback of the stub can run while aSynchronizecall is still in progress.Tests:
PrepareResourceClaims; the health endpoints.tests/integration, kind):TestNRILifecycleAndContainerdRestartstops and restarts containerd. It checks the health endpoints during the outage, that a pod created during the outage gets its interface after the runtime is back, and that DRANET keeps its PID.Which issue(s) this PR is related to:
Fixes #88
Related to #424
Related to #310
Special notes for your reviewer:
Known limit, in short. A pod can still start without its claimed interfaces if the runtime does not have the DRANET plugin at the moment that the kubelet creates the sandbox of a pod whose claims are already prepared. That needs a fault on the node at that moment:
SIGKILL). A graceful stop, for example an update of the DaemonSet, is safe.In both cases something is wrong on the node, and the missing interface is the smaller problem. One cause is not a fault of the node: a panic in a DRANET hook. DRANET does not recover from a panic, so a bug there has the same effect as a kill.
DRANET does not report such a pod in this PR, so the pod runs without the interfaces and nothing shows it. #427 adds the report: a
Warningevent on the Pod and a metric.The case that stays open. DRANET is down without a graceful shutdown (crash, OOM kill,
SIGKILL), and in that time the kubelet creates a sandbox for a pod that has its claims already prepared. DRANET cannot close this case, because it is not running when it happens.How it happens:
1. The kubelet marks a claim as prepared after
NodePrepareResources. It does not callNodePrepareResourcesagain for that pod. It only requires that the driver is registered.2. A process that is killed does not remove its registration socket, so the kubelet keeps the driver as registered.
3. The kubelet creates the sandbox. The runtime does not have the DRANET NRI plugin, so the sandbox does not get the claimed interfaces. The containers start, and nothing repairs the pod later.
It is unlikely, because it needs two things at the same time:
Stopstops the DRA plugin first, that removes the registration socket, and the kubelet then refuses to create the sandbox (FailedPrepareDynamicResources).NodePrepareResourcesandRunPodSandboxwhen DRANET stopped, or a running pod whose sandbox stops and is created again. A pod that is created later is safe: itsNodePrepareResourcescall fails while DRANET is down.Measured on the kind node of
tests/integration:RunPodSandboxhook started 232 ms after the end ofNodePrepareResources. A crash must be in this time, or the sandbox of a running pod must stop while DRANET is down.SIGKILLof DRANET, the registration socket stayed. The sandbox of a running pod was stopped, and the kubelet made a new sandbox after 1.3 s, withloandeth0only.SIGTERMof DRANET, the registration socket was removed. The sandbox of a running pod was stopped, and the kubelet made no new sandbox in 40 s.To close this case needs a check in the runtime at
RunPodSandbox(containerd/nri#142) or a DRA call after the sandbox exists.Two related limits:
cc @gauravkghildiyal
Does this PR introduce a user-facing change?
``
release-note/healthzDRANET connects its NRI plugin before it registers its DRA plugin, connects again when the container runtime restarts instead of exiting, and rejects new claims while the NRI plugin is not connected.
now also fails while the NRI plugin is not connected, and the new/healthz/draand/healthz/nriendpoints report each check.Known limit: a pod can still start without its claimed network interfaces if DRANET is killed or panics, or if the container runtime restarts, at the moment that the kubelet creates the sandbox of the pod. A graceful stop of DRANET, for example an update, is safe.
``