nri-image-policy: recover running member pods on a plugin restart #1096
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 #1096"
general
weight: 0.35
joaosa
What this does
When the nri-image-policy enforcer reconnects to a node with member pods
already running — a plugin restart, or containerd restarting under it — it
takes each pod back under the mesh gate from what the sandbox itself shows:
the proven network namespace, the live ruleset in it, and the containers the
runtime lists. A pod it cannot take back is refused for its life.
Rebase and the two recovery fixes it surfaced
Rebased onto
main, which now carries declared egress ("exits") per workloadentry. Verifying a recovered pod's ruleset now has to account for the exits it
was granted, and wiring that up surfaced two ways a member pod was refused for
life across an enforcer restart:
recovered pod holds were taken from the admission inventory, which a restarted
process has not repopulated when recovery runs; and recovery ran at connect,
before the served allowlist that declares egress had applied. Now a recovered
pod's exits are decided from the launches the enforcer reads back from the
runtime, and recovery is deferred alongside the startup check so it runs once
a served allowlist is present. A pod whose exits cannot be decided (no served
allowlist yet) or whose match is refused is granted none and verified against
the base mesh ruleset: a pod whose live ruleset is exactly that recovers, and
only one still holding exits is refused, with the cause named. A
created-but-never-run container is left out of the match, as admission never
counted it.
runtime labels the same namespace differently at different times — the
sandbox's CNI path at creation, a
/proc/<pid>/ns/nethandle in a Synchronizereplay — so a string comparison read the relabelling as a move and refused the
container, and with it the pod. Now the reported namespace is resolved to its
kernel identity (device and inode) and compared to the sandbox's, as the
namespace proof already does. A container not running, or one reported running
whose
/prochandle is already gone, moves no packets and is not checked.Behaviour changes
enforce_existingand whether an inventory is configured, so it runs on a restart however the
check is configured;
RunDeferredCheckconsumes the deferred batchunconditionally.
briefly not on the gate's record. A token request for it, and a container
create that reaches the mesh gate, are refused transiently and retried, not
for the pod's life: the gate distinguishes a sandbox recovery has not yet
reached (transient) from one still unknown after recovery (refused for life).
recovery reads a container's liveness from the running set, not only the
registration snapshot, which does not see a container that started after it
was taken.
Known limitations
serves only its base allowlist), a pod that was granted exits cannot have them
decided and is refused until an allowlist applies; ordinary member pods, whose
ruleset is the base mesh ruleset, are unaffected.
namespace handle comes from the Synchronize snapshot: a container that exits
in the deferral window, or pid reuse within it, can leave that handle stale
until the stop event lands.
not counted toward the recovered pod's exit decision: it is gone from the
running set and was created, not running, in the snapshot. Narrow, and its
mesh membership is unaffected.
re-deciding those exits against the node's current served allowlist. If the
served allowlist changed after the pod started so that it no longer resolves
the same exits, recovery does not re-admit that pod, because its live firewall
ruleset no longer matches what the current allowlist would grant. A running
pod's exits are otherwise fixed for its life, so this only affects a pod caught
by an allowlist change across a plugin restart.
Verification
mainat788e4fdb; the branch is four commits on top of it,all signed, working tree clean.
go vetpasses on the package for bothGOOS=linuxandGOOS=darwin; the//go:build linuxrecovery tests compile underGOOS=linux. The fullpackage
go testpasses except for the health/attestation unix-socket tests,which fail only on macOS because the temp socket path exceeds the platform's
sun_pathlimit — an environment limit, not a regression, and they pass inCI.
the launches read back, and matching a recovered container's namespace by
kernel identity — are exercised on a real network namespace under the
nftables-required suite, which runs in CI (Build & Test and Coverage gate
both green on the rebased tip).
boot a node CVM from the published node image for the commit under test, and
those images are built only for
maincommits (about 40 minutes after amerge), never for a branch tip — so this branch cannot be run on the metal
lanes. Once this merges, the post-merge
maincommit's lanes verify themesh-recovery behaviour; the regression this fixes was a running pod refused
on the old string-based namespace comparison, so the check is that a mesh
member's leaf renews across a mid-run containerd restart.