Repository navigation
fix(cni,agent): CNI DEL no longer blocks on the agent; stale-netns pods kept out of every snapshot (#796) - #798
Merged
Merged
Conversation
… delay and let the ghost sweep reconcile (#796) CmdDel returned the DEL error whenever `sendRemovePod` failed, on the grounds that unpinning a netns the agent had not yet ACKed reintroduced the Envoy segfault of #112/#245. containerd retries a failed DEL forever, so when the agent pod was simply *gone* the sandbox could never be torn down: the Terminating pod kept its CPU request, the node's own replacement agent/proxy/mesh-dns pods hit `Insufficient cpu`, and worker-03 ran unmanaged for 12m47s (#796). The premise no longer holds. The pinned proxy snapshot (1.40.0-dev.20260904.13144fb) contains envoyproxy/envoy#45975 — an upstream dial into a vanished netns is a `FailedToCreateConnection` pool failure (a clean `UF`) instead of a nullptr deref — and envoyproxy/envoy#46503, which closes the second crash site by making the active TCP/HTTP/gRPC health checkers record a `NETWORK` failure rather than crash on the same dial. (#45976, opt-in netns validation at config load, is in the snapshot too and stays OFF: it would turn a stale pod into an LDS/CDS NACK, which is worse than a clean dial failure.) A stale per-pod cluster now costs at most one failed request and an unhealthy host until the agent prunes it. CmdDel therefore classifies the failure instead of blanket-returning it: - `agentUnreachable` — the socket file is gone, or the RPC came back `codes.Unavailable` / `DeadlineExceeded` / `Canceled`, or an unwrapped ENOENT/ECONNREFUSED reached us. Nothing answered, and nothing will ACK a retry: log WARN "agent unreachable at CNI DEL; unpinning on the normal delay and letting the ghost sweep reconcile", skip the DEL readiness probe (there is no agent to have removed the listener, so the probe can only burn its whole timeout), spawn the usual detached unpinner on `NetnsUnpinDelay`, and return nil so the sandbox teardown completes and the CPU request is released. - any other RPC error — a live agent answered, still owns the pod's xDS resources, and will ACK a retry: unchanged behaviour, return the error and let containerd retry with the netns still pinned. That second branch is bounded rather than infinite: a new conflist key `netns_del_give_up_after_seconds` (`AetherConf.NetnsDelGiveUpAfter()`, default 5m, negative = give up at once) caps how long a live-but-erroring agent can hold the node. The plugin process lives for exactly one CNI call, so the first failure's timestamp is kept in a `<pin>.delfail` marker beside the netns pin; past the bound the DEL degrades to the unreachable path. The marker is cleared on a successful DEL and on the give-up path, and `sweepNetnsPins` now recognises markers so CNI GC neither treats one as a pin nor resets the bound of a DEL that is still being retried. The pin and the unpin delay both stay. The window they cover is real even without a crash: a hot-restart successor re-creates the pod's listeners, and deferred dials (health checkers and pool drains were measured 10-13s after removal under churn) still *fail* through a released pin — they merely fail cleanly now instead of taking the node proxy down. Seams for the tests in the following commit: `spawnDetachedUnpinFn` and `delReadinessWait` indirect the process fork and the DEL probe. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…egfault (#796) Comments-only. Several of them still described the deleted-netns SIGSEGV as current Envoy behaviour, which is what made "CNI DEL must block until the agent ACKs" look mandatory rather than merely conservative. All three relevant fixes are in the pinned proxy snapshot 1.40.0-dev.20260904.13144fb: - envoyproxy/envoy#45975 (2026-07-13) — the pool dial into a vanished netns returns FailedToCreateConnection / LocalConnectionFailure (a clean UF for that request) instead of a nullptr the caller dereferences. - envoyproxy/envoy#46503 (2026-08-11) — the active TCP/HTTP/gRPC health checkers, which build upstream connections directly and so still crashed after #45975, record a NETWORK health-check failure instead. This is the "cold-start health checkers dial immediately → proxy unbootable" case of #245. - envoyproxy/envoy#45976 (2026-08-27) — opt-in netns validation at config load. Also in the snapshot; stays OFF, because it would turn a stale pod into an LDS/CDS NACK, which is worse than a clean dial failure. Rewritten: - cni/internal/plugin/netnspin.go — package comment: the crash is history, cites the three PRs and the snapshot, and states why the pin and the unpin delay stay. The window is still real (a hot-restart successor re-creating the pod's listeners; deferred dials measured 10-13s after removal), it is just the difference between those dials working and failing cleanly rather than between the node proxy living and dying. Also notes that CNI DEL no longer waits on the agent's ACK to unpin. - cni/internal/plugin/plugin.go — the ADD-side pin-failure fallback no longer calls the fallback "the old crash window". - cni/config/config.go — NetnsPinDisabled, NetnsUnpinDelaySeconds and defaultNetnsUnpinDelay: same correction, same citations. The pin is a data-plane-quality measure now, not a crash guard. - agent/internal/xds/cache/listener.go — the missing-netns skip in LoadListenersFromStorage KEEPS its behaviour; only the reason changes. It is no longer "this faults Envoy", it is "this config can never become correct again, so programming it buys nothing but health-check noise against a host that will never come back". - agent/internal/cni/server/ghostsweep.go — the sweep header and pruneStaleStoragePods: the stale entry a lost DEL leaves behind now also arrives via the #796 path (the plugin completes the DEL without the agent and leaves reconciliation here), and its cost is a clean failure plus an eternally unhealthy host rather than a crash. The supervisor's crash budget (#245, agent/internal/proxy/hotrestart) is untouched and stays as the last line of defence. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…agent (#796) CmdDel had no direct test at all — the DEL path was only exercised through CNIClient unit tests, which is why "the agent is gone" could keep returning the dial error unnoticed. New cni/internal/plugin/cmddel_test.go drives CmdDel end to end against a fake CNI service on a real Unix socket (the plugin builds its own client from the netconf path, so bufconn cannot stand in), with two seams added in the first commit stubbed out: spawnDetachedUnpinFn (no process forked, the scheduled target and delay recorded) and delReadinessWait (counted, never run). (a) TestCmdDelAgentUnreachableSucceedsAndUnpins — socket path absent: DEL returns nil, the unpin is scheduled on the pin path with the ordinary 60s delay, the readiness probe is NOT awaited, and no marker is written. THIS TEST FAILS ON MAIN. Verified by restoring the pre-fix classification locally: "Received unexpected error: failed to remove pod from agent: rpc error: code = Unavailable desc = ... dial unix .../absent.sock: connect: no such file or directory". (b) TestCmdDelAgentErrorRetriesAndMarks — socket present, agent answers codes.Internal: DEL returns the error, nothing is unpinned, and the <pin>.delfail marker is written with a parseable first-failure timestamp. (c) TestCmdDelAgentErrorPastGiveUpDegrades — same, with a marker 10m old against the 5m default: DEL returns nil, the unpin is scheduled, the marker is removed. (d) TestCmdDelAgentOKUnchanged — agent ACKs: RemovePod reached it with the right pod name, the DEL readiness wait ran exactly once, the unpin is scheduled, no marker. Plus the edges that make the bound trustworthy rather than decorative: TestCmdDelAgentErrorWithinGiveUpStillRetries (a young marker does not degrade the DEL, and a later attempt must not refresh the timestamp the bound is measured from), TestCmdDelClearsStaleMarkerOnSuccess (or the next container to reuse the ID starts with an already-expired bound), TestSweepNetnsPinsHandlesDelMarkers (CNI GC must not mistake a marker for a pin — unpinning one would silently reset the bound of a DEL still in flight — and must take an orphan's marker with the orphan), and TestAgentUnreachableClassification, a table over the classifier itself including the wrapped-status forms CmdDel actually receives. cni/config: TestNetnsDelGiveUpAfter and TestNetnsDelGiveUpAfterFromNetconf pin the 5m default, the negative "give up at once" spelling and the conflist key. Also corrects one stale comment in netnspin_test.go that still called a dial through a released pin a segfault. Verification: bazel test //cni/... passes; the three touched test targets pass under --config=race --runs_per_test=3 (image targets are excluded from the race run — rules_go refuses race instrumentation with cgo disabled). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
… first (#796, #717) An experiment against the pinned proxy (1.40.0-dev.20260904.13144fb, Envoy source 13144fb) settled what a dangling `network_namespace_filepath` does on the LISTENER path, which is the one case envoyproxy/envoy#45975 and #46503 do not cover: - A listener whose netns file is missing is REJECTED, not fatal: `listener_create_failure+1`, `lds.update_rejected+1`, process alive, manager still usable. No crash anywhere. - But a HOT-RESTART SUCCESSOR asked (LDS) to create such a listener NACKs the whole SotW response and comes up with ZERO listeners — every listener on the node, not just the stale one — and the port dies when the parent finishes draining. `createListenSocket()` jumps into the netns BEFORE it calls `duplicateParentListenSocket()` (the netns jump wraps the entire `createListenSocketInternal()` body, parent handoff included), so a listener that rode the previous handoff fine is silently dropped at the next one. - An in-place LDS MODIFY of such a listener is ACCEPTED: `hasCompatibleAddress` matches on the netns string and the socket factory is cloned, so `createListenSocket()` is never called and the dangling path stays invisible until a remove+re-add or a hot restart. So the agent must not put a stale-netns pod in any snapshot. The existing skip in `LoadListenersFromStorage` only covers startup, and the window it does not cover is exactly the one #796 opens routinely: CNI DEL now completes without the agent, so between the unpin and the ghost sweep's next pass (≤60s) the entry sits in `c.listeners` with a netns that no longer exists — and that is precisely when a proxy roll is likely, since the agent being absent usually means the node is rolling. - `SnapshotCache.staleNetns` (reusing the existing `netnsExists` seam) is consulted in `meshListeners()` and `appClusters()`, so neither the per-pod listeners nor the per-pod app/health clusters (which carry the same netns) reach a generation. One stat per pod per regeneration. - WARN `skipping pod with missing network namespace in snapshot generation` is rate-limited to once per pod (`staleNetnsWarned`, its own mutex — the read paths hold only `listenerMu.RLock`), and forgotten on RemovePod so a reused netns can warn again. Without the limit a stale entry would log on every regeneration for a minute. - New counter `aether.agent.snapshot.stale_netns_skipped`, incremented once per stale pod per generation from the listener pass only (appClusters applies the same filter but must not double-count), and SEEDED AT ZERO at registration like the #638 discriminators — an unseeded counter that is never incremented never appears in Prometheus, and "no series" grades the same as "zero". The ghost sweep still owns the actual prune; this only keeps the bad config out of the wire in the meantime. The load-time skip stays. Tests (agent/internal/xds/cache/stalenetns_test.go): two pods registered with live namespaces, one netns then removed → the snapshot carries only the live pod's listeners AND only its per-pod clusters, counter 1, one WARN naming the pod; three generations → counter 3, still one WARN; after RemovePod the counter stays (a counter keeps the evidence, it does not reset), and a healthy node exports an explicit zero. Verification: bazel test //agent/internal/xds/cache:all passes, and the cache + cachemetrics targets pass under --config=race --runs_per_test=3. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
) Teaching the sweep about `.delfail` markers pushed sweepNetnsPins to a cognitive complexity of 21, over the repo's gocognit threshold of 15 (the #556 campaign's target), so `--config=lint` failed the build. The per-entry decision — marker, pin still backing a valid attachment, or orphan to release — moves into sweepPinEntry, which is the whole of the added branching and reads better on its own anyway. No behaviour change; the sweep tests cover it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…ries (#245, #796, #717) The #796 outage had no runbook entry, and the #245 stale-netns story was only in code comments and agent memory. New troubleshooting section "A pod is stuck `Terminating`, or a node has stale netns entries", covering both symptoms of one mechanism (a CNI DEL that never completed): - Symptom A, the sandbox that will not tear down: what it looks like, why the Terminating pod's retained CPU request starves that node's own DaemonSets, and why priority cannot break the loop (the scheduler refuses to preempt on a node with a terminating pod). Then what the plugin now does instead — the two classes of DEL failure, the WARN each emits, the `netns_del_give_up_after_seconds` bound and its `<pin>.delfail` marker — so the reader knows that a pod STILL stuck means either a live agent refusing the removal or a failure outside aether. Commands to tell which, before force-deleting. - Symptom B, stale storage entries for pods that no longer exist: expected after the unreachable path, self-healing, do not hand-edit the registry. The three layers that heal it (the load-time skip, the per-generation skip, the ghost sweep) and the metrics to watch: `aether_agent_ghost_sweep_stale_pruned_total` and the new `aether_agent_snapshot_stale_netns_skipped_total`, both seeded so a flat zero is a real reading, with the usual false-zero warning about the metric family name. - Why the stale entry is no longer dangerous on the upstream side (envoyproxy/envoy#45975, #46503 in the pinned snapshot; #45976 deliberately off) — and why the LISTENER side still needs the agent to filter: a hot-restart successor asked to create a listener in a vanished netns NACKs the whole LDS response and comes up with ZERO listeners, while an in-place LDS modify of the same listener is silently accepted, so "LDS is being accepted" must not be read as "no stale netns" (#717). Envoy-side stats to check after a roll. docs/configuration.md: the netconf keys the plugin reads but `cni-install` does not write, including the new `netns_del_give_up_after_seconds`. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Sep 16, 2026
bpalermo
added a commit
that referenced
this pull request
Sep 18, 2026
…#804) (#805) pruneOnePod removed a pruned pod's storage entry and listener but never unsubscribed its SPIRE stream; RemovePod was the only teardown path that did. A pod whose CNI DEL ran while the agent was down (routine since #798) is resubscribed from storage on restart, pruned by the sweep a pass later, and its subscription then asks the Broker for a pod that no longer exists: NotFound, classified transient, retried at max backoff for the agent's lifetime. Seen on talos-main rev217 during the 2026-09-18 30-minute soak: main-worker-02 retrying one svc-3 pod at ~2/min after the TRIPLE step, with ghost_sweep_orphans_pruned_total = 1 for the same pod. No data-path cost; the cost is a leaked goroutine per pod and a reference_not_found counter that stops meaning anything. The sweep now calls UnsubscribePod for the pruned netns. Bridge gains a Subscribed(netns) accessor for the regression test, which fails without the fix. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Sep 19, 2026
…wns the recovery (#766) Three sites logged ERROR for a retry that is expected to fail once and heals by itself, so "zero ERROR lines" stopped being a usable bar for deploy and soak grading. Each keeps ERROR for the case where the excuse no longer holds. - xDS initial snapshot (the edge): the edge does not hold its first snapshot for identity, so with no SVID yet it cannot handshake with the registrar, exhausts the 15s budget and starts local-only — at ERROR, on every healthy roll. It now gets a severity-only view of its identity (SetIdentityWatch): WARN while the SVID is pending, and the background retry escalates to ERROR once if identity arrives and three more loads still fail. With the SVID in hand the ERROR is unchanged. The node agent is unaffected (it holds for identity first). - Broker subscribe (the agent): Unavailable is WARN until the subscription has been failing for 2 minutes (the readiness dwell), then ERROR. A restarted agent resubscribes before its own SVID has landed, and a SPIRE agent restart removes the socket for ~35s: both cost one ERROR per managed pod per attempt and healed in seconds at zero prober cost. - Pod termination (the agent): the failed DRAINING mark has a fallback and is WARN. The fallback failing too stays ERROR — a terminating pod remains selectable — unless this agent's SVID is pending, when no registry call could have succeeded. The message said "CNI DEL will retry"; since #798 a DEL does not retry against an agent that is down, so it now names the real owners: the pod's CNI DEL or the next ghost sweep. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 19, 2026
…wns the recovery (#766) (#807) * fix(agent,edge): designed startup retries log at WARN, and name who owns the recovery (#766) Three sites logged ERROR for a retry that is expected to fail once and heals by itself, so "zero ERROR lines" stopped being a usable bar for deploy and soak grading. Each keeps ERROR for the case where the excuse no longer holds. - xDS initial snapshot (the edge): the edge does not hold its first snapshot for identity, so with no SVID yet it cannot handshake with the registrar, exhausts the 15s budget and starts local-only — at ERROR, on every healthy roll. It now gets a severity-only view of its identity (SetIdentityWatch): WARN while the SVID is pending, and the background retry escalates to ERROR once if identity arrives and three more loads still fail. With the SVID in hand the ERROR is unchanged. The node agent is unaffected (it holds for identity first). - Broker subscribe (the agent): Unavailable is WARN until the subscription has been failing for 2 minutes (the readiness dwell), then ERROR. A restarted agent resubscribes before its own SVID has landed, and a SPIRE agent restart removes the socket for ~35s: both cost one ERROR per managed pod per attempt and healed in seconds at zero prober cost. - Pod termination (the agent): the failed DRAINING mark has a fallback and is WARN. The fallback failing too stays ERROR — a terminating pod remains selectable — unless this agent's SVID is pending, when no registry call could have succeeded. The message said "CNI DEL will retry"; since #798 a DEL does not retry against an agent that is down, so it now names the real owners: the pod's CNI DEL or the next ghost sweep. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * fix(agent): an established Broker stream ending is WARN; the bridge's ladder owns escalation (#766) Seen on the GitOps #77 phase-2 spire-agent roll (2026-09-19 12:03-12:06Z): 39 ERROR lines, one per managed pod, next to the 117 Unavailable ones the previous commit already demotes. Resubscribe was 17.2-17.8s per node at zero prober cost. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * refactor(agent): split the two severity decisions into helpers (gocognit) CI's cognitive-complexity lint rejected retryInitialRegistryLoad and handlePodTerminating after the previous commits; behaviour unchanged. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #796 (fix 1 + the snapshot-side guard from the Envoy listener experiment). Relies on envoyproxy/envoy#45975 + #46503 being in the pinned proxy (they are: snapshot 13144fb). Cluster validation: agent pod deleted on one node, app pod deleted there → DEL succeeds, pod terminates, node stays managed once the agent returns; proxy roll during the window → no listener loss.
fix(cni): CNI DEL no longer blocks on the agent — unpin on the normal delay and let the ghost sweep reconcile (#796)
CmdDel returned the DEL error whenever
sendRemovePodfailed, on the groundsthat unpinning a netns the agent had not yet ACKed reintroduced the Envoy
segfault of #112/#245. containerd retries a failed DEL forever, so when the
agent pod was simply gone the sandbox could never be torn down: the
Terminating pod kept its CPU request, the node's own replacement
agent/proxy/mesh-dns pods hit
Insufficient cpu, and worker-03 ran unmanagedfor 12m47s (#796).
The premise no longer holds. The pinned proxy snapshot
(1.40.0-dev.20260904.13144fb) contains envoyproxy/envoy#45975 — an upstream dial
into a vanished netns is a
FailedToCreateConnectionpool failure (a cleanUF)instead of a nullptr deref — and envoyproxy/envoy#46503, which closes the second
crash site by making the active TCP/HTTP/gRPC health checkers record a
NETWORKfailure rather than crash on the same dial. (#45976, opt-in netns validation at
config load, is in the snapshot too and stays OFF: it would turn a stale pod into
an LDS/CDS NACK, which is worse than a clean dial failure.) A stale per-pod
cluster now costs at most one failed request and an unhealthy host until the
agent prunes it.
CmdDel therefore classifies the failure instead of blanket-returning it:
agentUnreachable— the socket file is gone, or the RPC came backcodes.Unavailable/DeadlineExceeded/Canceled, or an unwrappedENOENT/ECONNREFUSED reached us. Nothing answered, and nothing will ACK a
retry: log WARN "agent unreachable at CNI DEL; unpinning on the normal delay
and letting the ghost sweep reconcile", skip the DEL readiness probe (there is
no agent to have removed the listener, so the probe can only burn its whole
timeout), spawn the usual detached unpinner on
NetnsUnpinDelay, and returnnil so the sandbox teardown completes and the CPU request is released.
resources, and will ACK a retry: unchanged behaviour, return the error and let
containerd retry with the netns still pinned.
That second branch is bounded rather than infinite: a new conflist key
netns_del_give_up_after_seconds(AetherConf.NetnsDelGiveUpAfter(), default5m, negative = give up at once) caps how long a live-but-erroring agent can hold
the node. The plugin process lives for exactly one CNI call, so the first
failure's timestamp is kept in a
<pin>.delfailmarker beside the netns pin;past the bound the DEL degrades to the unreachable path. The marker is cleared
on a successful DEL and on the give-up path, and
sweepNetnsPinsnow recognisesmarkers so CNI GC neither treats one as a pin nor resets the bound of a DEL that
is still being retried.
The pin and the unpin delay both stay. The window they cover is real even
without a crash: a hot-restart successor re-creates the pod's listeners, and
deferred dials (health checkers and pool drains were measured 10-13s after
removal under churn) still fail through a released pin — they merely fail
cleanly now instead of taking the node proxy down.
Seams for the tests in the following commit:
spawnDetachedUnpinFnanddelReadinessWaitindirect the process fork and the DEL probe.docs(cni,agent): the stale-netns dial is a clean failure now, not a segfault (#796)
Comments-only. Several of them still described the deleted-netns SIGSEGV as
current Envoy behaviour, which is what made "CNI DEL must block until the agent
ACKs" look mandatory rather than merely conservative. All three relevant fixes
are in the pinned proxy snapshot 1.40.0-dev.20260904.13144fb:
returns FailedToCreateConnection / LocalConnectionFailure (a clean UF for
that request) instead of a nullptr the caller dereferences.
checkers, which build upstream connections directly and so still crashed
after #45975, record a NETWORK health-check failure instead. This is the
"cold-start health checkers dial immediately → proxy unbootable" case of
fix(agent,proxy): prune stale-netns pods + supervisor crash-fast-fail #245.
load. Also in the snapshot; stays OFF, because it would turn a stale pod
into an LDS/CDS NACK, which is worse than a clean dial failure.
Rewritten:
cites the three PRs and the snapshot, and states why the pin and the unpin
delay stay. The window is still real (a hot-restart successor re-creating
the pod's listeners; deferred dials measured 10-13s after removal), it is
just the difference between those dials working and failing cleanly rather
than between the node proxy living and dying. Also notes that CNI DEL no
longer waits on the agent's ACK to unpin.
calls the fallback "the old crash window".
defaultNetnsUnpinDelay: same correction, same citations. The pin is a
data-plane-quality measure now, not a crash guard.
LoadListenersFromStorage KEEPS its behaviour; only the reason changes. It is
no longer "this faults Envoy", it is "this config can never become correct
again, so programming it buys nothing but health-check noise against a host
that will never come back".
pruneStaleStoragePods: the stale entry a lost DEL leaves behind now also
arrives via the Roll on a CPU-saturated node wedges: edge maxSurge pod preempted by the proxy DS, CNI DEL fails while the agent socket is gone, Terminating pod holds the CPU the agent needs #796 path (the plugin completes the DEL without the agent
and leaves reconciliation here), and its cost is a clean failure plus an
eternally unhealthy host rather than a crash.
The supervisor's crash budget (#245, agent/internal/proxy/hotrestart) is
untouched and stays as the last line of defence.
test(cni): cover CmdDel against a missing, an erroring and a healthy agent (#796)
CmdDel had no direct test at all — the DEL path was only exercised through
CNIClient unit tests, which is why "the agent is gone" could keep returning the
dial error unnoticed. New cni/internal/plugin/cmddel_test.go drives CmdDel
end to end against a fake CNI service on a real Unix socket (the plugin builds
its own client from the netconf path, so bufconn cannot stand in), with two
seams added in the first commit stubbed out: spawnDetachedUnpinFn (no process
forked, the scheduled target and delay recorded) and delReadinessWait (counted,
never run).
(a) TestCmdDelAgentUnreachableSucceedsAndUnpins — socket path absent: DEL
returns nil, the unpin is scheduled on the pin path with the ordinary 60s
delay, the readiness probe is NOT awaited, and no marker is written.
THIS TEST FAILS ON MAIN. Verified by restoring the pre-fix classification
locally: "Received unexpected error: failed to remove pod from agent: rpc
error: code = Unavailable desc = ... dial unix .../absent.sock: connect:
no such file or directory".
(b) TestCmdDelAgentErrorRetriesAndMarks — socket present, agent answers
codes.Internal: DEL returns the error, nothing is unpinned, and the
.delfail marker is written with a parseable first-failure timestamp.
(c) TestCmdDelAgentErrorPastGiveUpDegrades — same, with a marker 10m old
against the 5m default: DEL returns nil, the unpin is scheduled, the
marker is removed.
(d) TestCmdDelAgentOKUnchanged — agent ACKs: RemovePod reached it with the
right pod name, the DEL readiness wait ran exactly once, the unpin is
scheduled, no marker.
Plus the edges that make the bound trustworthy rather than decorative:
TestCmdDelAgentErrorWithinGiveUpStillRetries (a young marker does not degrade
the DEL, and a later attempt must not refresh the timestamp the bound is
measured from), TestCmdDelClearsStaleMarkerOnSuccess (or the next container to
reuse the ID starts with an already-expired bound),
TestSweepNetnsPinsHandlesDelMarkers (CNI GC must not mistake a marker for a pin
— unpinning one would silently reset the bound of a DEL still in flight — and
must take an orphan's marker with the orphan), and
TestAgentUnreachableClassification, a table over the classifier itself
including the wrapped-status forms CmdDel actually receives.
cni/config: TestNetnsDelGiveUpAfter and TestNetnsDelGiveUpAfterFromNetconf pin
the 5m default, the negative "give up at once" spelling and the conflist key.
Also corrects one stale comment in netnspin_test.go that still called a dial
through a released pin a segfault.
Verification: bazel test //cni/... passes; the three touched test targets pass
under --config=race --runs_per_test=3 (image targets are excluded from the race
run — rules_go refuses race instrumentation with cgo disabled).
fix(agent): keep stale-netns pods out of EVERY snapshot, not just the first (#796, #717)
An experiment against the pinned proxy (1.40.0-dev.20260904.13144fb, Envoy
source 13144fb) settled what a dangling
network_namespace_filepathdoes on theLISTENER path, which is the one case envoyproxy/envoy#45975 and #46503 do not
cover:
listener_create_failure+1,lds.update_rejected+1, process alive, managerstill usable. No crash anywhere.
whole SotW response and comes up with ZERO listeners — every listener on the
node, not just the stale one — and the port dies when the parent finishes
draining.
createListenSocket()jumps into the netns BEFORE it callsduplicateParentListenSocket()(the netns jump wraps the entirecreateListenSocketInternal()body, parent handoff included), so a listenerthat rode the previous handoff fine is silently dropped at the next one.
hasCompatibleAddressmatches on the netns string and the socket factory is cloned, so
createListenSocket()is never called and the dangling path stays invisibleuntil a remove+re-add or a hot restart.
So the agent must not put a stale-netns pod in any snapshot. The existing skip in
LoadListenersFromStorageonly covers startup, and the window it does not coveris exactly the one #796 opens routinely: CNI DEL now completes without the agent,
so between the unpin and the ghost sweep's next pass (≤60s) the entry sits in
c.listenerswith a netns that no longer exists — and that is precisely when aproxy roll is likely, since the agent being absent usually means the node is
rolling.
SnapshotCache.staleNetns(reusing the existingnetnsExistsseam) isconsulted in
meshListeners()andappClusters(), so neither the per-podlisteners nor the per-pod app/health clusters (which carry the same netns)
reach a generation. One stat per pod per regeneration.
skipping pod with missing network namespace in snapshot generationis rate-limited to once per pod (
staleNetnsWarned, its own mutex — theread paths hold only
listenerMu.RLock), and forgotten on RemovePod so areused netns can warn again. Without the limit a stale entry would log on
every regeneration for a minute.
aether.agent.snapshot.stale_netns_skipped, incremented onceper stale pod per generation from the listener pass only (appClusters
applies the same filter but must not double-count), and SEEDED AT ZERO at
registration like the Transient cross-service mTLS identity mis-binding during concurrent proxy-restart + service roll (failed closed) #638 discriminators — an unseeded counter that is
never incremented never appears in Prometheus, and "no series" grades the
same as "zero".
The ghost sweep still owns the actual prune; this only keeps the bad config out
of the wire in the meantime. The load-time skip stays.
Tests (agent/internal/xds/cache/stalenetns_test.go): two pods registered with
live namespaces, one netns then removed → the snapshot carries only the live
pod's listeners AND only its per-pod clusters, counter 1, one WARN naming the
pod; three generations → counter 3, still one WARN; after RemovePod the counter
stays (a counter keeps the evidence, it does not reset), and a healthy node
exports an explicit zero.
Verification: bazel test //agent/internal/xds/cache:all passes, and the cache +
cachemetrics targets pass under --config=race --runs_per_test=3.
refactor(cni): split the pin-sweep loop body out of sweepNetnsPins (#796)
Teaching the sweep about
.delfailmarkers pushed sweepNetnsPins to a cognitivecomplexity of 21, over the repo's gocognit threshold of 15 (the #556 campaign's
target), so
--config=lintfailed the build. The per-entry decision — marker,pin still backing a valid attachment, or orphan to release — moves into
sweepPinEntry, which is the whole of the added branching and reads better on its
own anyway. No behaviour change; the sweep tests cover it.
docs: runbook section for a stuck Terminating pod and stale netns entries (#245, #796, #717)
The #796 outage had no runbook entry, and the #245 stale-netns story was only in
code comments and agent memory. New troubleshooting section
"A pod is stuck
Terminating, or a node has stale netns entries", covering bothsymptoms of one mechanism (a CNI DEL that never completed):
Terminating pod's retained CPU request starves that node's own DaemonSets,
and why priority cannot break the loop (the scheduler refuses to preempt on
a node with a terminating pod). Then what the plugin now does instead —
the two classes of DEL failure, the WARN each emits, the
netns_del_give_up_after_secondsbound and its<pin>.delfailmarker — sothe reader knows that a pod STILL stuck means either a live agent refusing
the removal or a failure outside aether. Commands to tell which, before
force-deleting.
after the unreachable path, self-healing, do not hand-edit the registry.
The three layers that heal it (the load-time skip, the per-generation skip,
the ghost sweep) and the metrics to watch:
aether_agent_ghost_sweep_stale_pruned_totaland the newaether_agent_snapshot_stale_netns_skipped_total, both seeded so a flatzero is a real reading, with the usual false-zero warning about the metric
family name.
(upstream: gracefully handle upstream connection creation failure envoyproxy/envoy#45975, #46503 in the pinned snapshot; #45976 deliberately
off) — and why the LISTENER side still needs the agent to filter: a
hot-restart successor asked to create a listener in a vanished netns NACKs
the whole LDS response and comes up with ZERO listeners, while an in-place
LDS modify of the same listener is silently accepted, so "LDS is being
accepted" must not be read as "no stale netns" (fix(agent): seed the #638 identity mismatch counters at zero (false-zero in Prometheus) #717). Envoy-side stats to
check after a roll.
docs/configuration.md: the netconf keys the plugin reads but
cni-installdoesnot write, including the new
netns_del_give_up_after_seconds.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr