Repository navigation
fix(agent): seed the #638 identity mismatch counters at zero (false-zero in Prometheus) - #717
Merged
Merged
Conversation
… absence is not a false zero (#638) The OTel SDK exports a counter only after its first Add. Both discriminator counters (outbound #686, inbound #715) are never incremented in the healthy case, so neither series existed in Prometheus on talos-main rev200 and a grading increase() would return no data, indistinguishable from zero. Seed both at process start; test pins it. 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 16, 2026
…784) `pushSecrets` was build-then-publish with no serialisation: it snapshotted `b.secrets` under `mu`, released it, and called `store.SetSecrets` — a whole-map replace. Four independent goroutines reach it (the bundle stream, every per-pod SVID stream, the node-SVID refresher, and `UnsubscribePod` off the CNI DEL path), so two overlapping pushes — an SVID rotation racing a bundle update, or a `Updated()` wake from #740's bridge changes — could land the older set on top of the newer one. Last writer wins, and a just-arrived secret disappears from the SDS snapshot until something else pushes. That is the "Secret is not supplied by SDS" / secret-absent WARN family, squarely inside the still-open #638 blast radius. (races report S10.) S11, same file: `handleBundleUpdate` deleted *every* validation-context secret and then re-added them one trust domain at a time, returning early on a conversion error. One malformed bundle mid-loop left the map with no trust bundles at all and no push — and the next push from any other goroutine then served Envoy a secret set with nothing to verify peers against. Design choice — a mutex plus a monotonic generation stamp, not a single-writer goroutine fed by a dirty signal: - `pushSecrets` keeps its synchronous error return. `UnsubscribePod` propagates it to the CNI DEL caller and the SVID/bundle handlers log it; a background writer would strand those errors with nowhere to go. - No new goroutine lifecycle to get right. `refreshNodeSVID` pushes from `Start` *before* the bundle loop is running, and `UnsubscribePod` pushes from the CNI server — a writer goroutine would have to outlive `Start`'s window or silently drop those pushes. - The generation stamp delivers the coalescing the single-writer shape was wanted for: overlapping wakes collapse, because a pusher that finds the store already holding its generation returns without a redundant `SetSecrets` (each one regenerates the whole node snapshot). Changes: - `bridge.go`: `gen` (guarded by `mu`, bumped by every secret mutation) and `pushMu` + `publishedGen`. `pushSecrets` holds `pushMu` across BOTH the build and the publish, so publishes happen in generation order and each carries the newest state at build time; `gen == publishedGen` is skipped as already-served and `gen < publishedGen` is rejected as stale. `publishedGen` advances only on a successful `SetSecrets`, so a failed push is retried by the next one. - `bridge.go` `handleBundleUpdate`: build the complete validation-context map in a local and swap it in under `mu` only once every trust domain converted; a conversion error now leaves the served bundles untouched. A response carrying zero trust bundles while non-empty contexts are already served is never a legitimate instruction to stop verifying peers: keep the previous ones, WARN, and count it. Bundles are keyed by the canonical secret name rather than the raw response key (they differ when SPIRE reports a bare trust domain). - `bridge.go` `handleSVIDUpdate`: convert before mutating, so a malformed SVID mid-response leaves the served set untouched instead of half-applied. - `metrics.go`: `aether.agent.sds_push.stale_rejected` and `aether.agent.sds_push.empty_bundle_skipped`, both seeded with `Add(ctx, 0)` at registration — the #717 lesson: the OTel SDK exports a counter only after its first Add, and both of these are zero in a healthy agent, so without seeding "never registered" and "zero" are indistinguishable to a grading query. Tests (`bridge_push_ordering_test.go`), all under `--config=race`: - `TestPushSecretsPublishesMonotonically` drives 150 rounds each of two concurrent SVID rotations and a bundle update against a store that records every published set in publish order, then asserts over the whole sequence: no identity's SVID version ever goes backwards or vanishes, no set is published without a validation context once one has been served, and the final publication carries the newest inputs with `publishedGen == gen`. - `TestHandleBundleUpdateKeepsBundlesOnConversionError` and `TestHandleBundleUpdateSkipsEmptyBundleSet` cover S11 from both sides. - `TestBridgeMetricsSDSPushCountersSeededAtZero` pins the seeding. Proof the old code fails these, measured by reverting each hunk in place: with the pre-fix `pushSecrets`, `TestPushSecretsPublishesMonotonically` failed 3 out of 3 `--runs_per_test` under `--config=race` ("push 61 regressed SVID .../sa/svc-b from v27 to v26", "push 16 ... v8 to v7", "push 13 ... v5 to v4"). With the pre-fix `handleBundleUpdate`, both S11 tests failed ("the previously served trust bundle must survive a failed update"; "an empty bundle update must not publish anything"). Verification: `bazel build //... //test/e2e:e2e_test`; `bazel test //...` (100 pass); `bazel test //agent/internal/spire/... //agent/internal/xds/... --config=race --runs_per_test=3` (9 targets, 27 runs, all pass); `bazel test //test/envoy_validate/...`; `bazel run //:format.check`; `bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //agent/...`; `bazel run //:gazelle` no churn; `bazel mod tidy` idempotent; `scripts/go-deps-audit.sh` exit 0. Data-plane change: needs a hitless-rollout validation on talos-main with the #638 discriminator counters (`aether_agent_identity_{inbound,outbound}_binding_mismatch_total`) flat across a proxy roll, plus the two new counters reading 0. Refs #772, #638, #717, #740. 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 16, 2026
…fore draining; graceful drain fallback (#795) (#797) #785 fixed the epoch-identity probe at shutdown (it had been running on an already-cancelled context and failing in microseconds without opening a socket), and in doing so removed the accident that had been keeping pod termination hitless. With the probe working, "admin LIVE at our own epoch" now correctly routed to s.shutdown() — a bare SIGTERM, which Envoy does not drain on. The supervisor then WON the race against its own DaemonSet surge replacement: rev214, two samples on worker-04/05, termination 2.27s/1.55s, the replacement logging "no live predecessor; starting fresh at epoch 0", 7.95s/8.11s with no Envoy on the node and 130/126 prober connection_errors, AetherProberLivenessErrors paging CRITICAL. Pre-#785 on rev213 the same delete took 21-23s, drained Envoy and cost zero prober errors. `kubectl delete pod` is also the code path of node drain, eviction and preemption. The design error is the premise that "no handoff in progress" means "nobody is coming". For a DaemonSet with maxSurge and a transparent-capture node proxy the replacement is created within ~1s of the deletionTimestamp and hot-restarts us. So the pre-#785 behaviour becomes deliberate and bounded, and the fallback becomes a real drain. handleShutdown now resolves a SIGTERM onto exactly one of four branches, off one authoritative /server_info probe (still on a detached ctx — #785's fix is kept, and it is now also what tells "answered at another epoch" apart from "did not answer at all"): admin LIVE at a NEWER epoch genuine mid-handoff -> wait for the successor's parent-shutdown protocol, bounded by #785's successorWaitBudget. -> handoff admin LIVE at OUR epoch no handoff yet -> keep the child SERVING and wait for the surge successor on the same budget (155s at the chart default). -> successor_wait admin unreachable child dead or main thread wedged; nothing to drain. -> child_dead budget expired, or --shutdown-drain-immediately POST /drain_listeners?graceful, wait --drain-time (10s as deployed), then SIGTERM and reap. -> drain_fallback A serving Envoy is never bare-SIGTERMed again: shutdown() is split into terminateChildren() plus the histogram, drainThenShutdown() wraps it with the graceful drain, and shutdown()'s doc now says where it is and is not correct. --shutdown-drain-immediately (default false, documented in docs/configuration.md, NOT set by the chart) is the escape hatch for a deployment where no replacement can overlap the pod; StateDir == "" takes the same path, since a supervisor with no cross-pod coordination can have no successor either. Observability (the drain path had none — "closing and draining listeners" is Envoy's line, not ours, and aether_supervisor_drain_duration_* has never reached Prometheus): - aether.supervisor.shutdown.branch counter, attribute aether.supervisor.shutdown.branch in {handoff, successor_wait, drain_fallback, child_dead}, SEEDED AT ZERO for all four (#717: the OTel SDK exports a counter only after its first Add, and this one is incremented exactly once per pod lifetime, so unseeded "never taken" and "never registered" are the same empty query). - aether.supervisor.drain.duration now spans the WHOLE fallback — the graceful drain window included — and is recorded even when Envoy exits during its own drain sequence, which is the case terminateChildren then has nothing to report. - INFO lines: "waiting for a successor before draining" (with the budget), "successor took over during shutdown wait", "no successor within budget; draining listeners", "listeners drained; stopping envoy". The existing WARN fallback line and every existing counter are kept. Tests (agent/internal/proxy/hotrestart/shutdown_test.go, extending #785's; fakeAdminServer gains a /drain_listeners handler recording hits and the query string): - TestHandleShutdownWaitsForTheSurgeSuccessor — LIVE at our epoch, budget 14s, successor arrives at 2s: the child is still tracked and undrained at 1s, the wait ends on the successor and not at the budget, zero drain calls, and the probe really reached the admin (#771's assertion, carried over). - TestHandleShutdownDrainsGracefullyWhenNoSuccessorArrives — LIVE at our epoch, budget 2s, nobody comes: /drain_listeners?graceful hit exactly once, the budget plus DrainTime is spent, then SIGTERM and reap. - TestHandleShutdownDrainsImmediatelyWhenToldTo — the escape hatch drains at once, still gracefully, without spending the budget. - TestHandleShutdownStopsADeadChildWithoutDraining — an unreachable admin is not asked to drain and does not enter a successor wait. - TestHandleShutdownWaitsForGenuineSuccessor and TestHandleShutdownFallsBackToDrainWhenNoSuccessorComes (the mid-handoff branch) are unchanged in behaviour; the latter now also asserts the fallback is the graceful drain. - TestShutdownBranchesSeededAtZero / TestShutdownBranchRecording. Proof the first test catches the production regression: with handleShutdown's body replaced by main's, TestHandleShutdownWaitsForTheSurgeSuccessor fails at shutdown_test.go:94 — "envoy was stopped while a surge successor could still have hot-restarted it" after 1.03s — because main takes the drain branch immediately and the child is already SIGTERMed and reaped. The two drain tests fail on main at 33ms with zero /drain_listeners hits. #785's TestHandleShutdownProbesOnDetachedCtxAndDrains asserted the very behaviour this issue reverses (drain immediately when LIVE at our own epoch), so it is rewritten rather than removed: its #771 assertion — that the branch decision was made off a probe that really reached the network — is carried into the new test above, which is also what still fails if the WithoutCancel is reverted. Docs: docs/runbook.md gains a supervisor/termination section with the four-branch table, what to expect on `kubectl delete pod` (~20-25s, zero data-plane cost, the log lines to grep, and why a 1-2s termination is the alarming outcome), and the PromQL for the seeded branch counter; docs/configuration.md documents --shutdown-drain-immediately and --termination-grace. No chart change. Verification: bazel build //... //test/e2e:e2e_test; bazel test //... (105 pass); bazel test --config=race --runs_per_test=3 on //agent/internal/proxy/hotrestart, //agent/internal/supervisorcmd and //agent/cmd/proxy-supervisor:deps_test; scripts/check-proxy-supervisor-deps.sh OK (the supervisor links none of the forbidden packages); //test/envoy_validate pass; bazel run //:format.check clean; bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //... clean; bazel run //:gazelle no churn; bazel mod tidy idempotent; scripts/go-deps-audit.sh OK. Refs #771, #785, #772. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
This was referenced Sep 16, 2026
bpalermo
added a commit
that referenced
this pull request
Sep 16, 2026
…ds kept out of every snapshot (#796) (#798) * 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 `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 * 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: - 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 * 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 <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 * 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_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 * refactor(cni): split the pin-sweep loop body out of sweepNetnsPins (#796) 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 * 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 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 --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
This was referenced Sep 16, 2026
bpalermo
added a commit
that referenced
this pull request
Sep 18, 2026
…Broker API (#800) (036) (#802) Proposal 036, phase 1: a hard switch, not an opt-in. The node agent no longer mints per-pod SVIDs through SPIRE's proprietary Delegated Identity API on the agent admin socket with a selector set it builds by hand; it presents a KubernetesObjectReference over the standard SPIFFE Broker Endpoint and SPIRE resolves and attests the referenced pod itself. The delegated client, the admin-socket plumbing and the spire-api-sdk dependency are deleted. What that buys: every selector SPIRE's Kubernetes attestor can produce (pod labels, container image, sigstore) becomes usable in a registration entry — under the delegated path an entry keyed on anything other than the four selectors the agent supplied could never match, because SPIRE never attested the pod. The all-or-nothing admin socket and its authorizedDelegates allow-list disappear, and the agent speaks a SPIFFE standard rather than a SPIRE API. agent/internal/spire/client.go is now a Broker client: it dials unix://<broker socket> with mutual TLS built from the agent's own WaitingSource identity, authorises the server as a SPIFFE ID in our OWN trust domain under /spire/agent/ (the endpoint spec requires the broker to authenticate the provider, and "any member of the trust domain" would let any workload that can bind the socket path hand us poisoned SVIDs), and adds the mandatory broker.spiffe.io: true metadata on every unary and streaming call via interceptors. #740 semantics carry over unchanged: no SVID yet simply means the handshake cannot complete, the subscribe fails, and the bridge retries — the agent never exits. Two things the delegated path never had to handle: - A reference resolves at REQUEST time, so a CNI ADD routinely beats the pod into the kubelet's pod list and gets NotFound. SubscribePod therefore never blocks on the broker: it registers the subscription and hands the first subscribe to the subscription's own goroutine, which retries on the existing jittered backoff. The gRPC codes are mapped per the proposal's Errors bullet (NotFound/FailedPrecondition retry, PermissionDenied retries slowly, Unauthenticated retries — go-spiffe re-reads the SVID per handshake, so a plain retry IS the credential refresh —, InvalidArgument never retries), with new counters aether.agent.spire.broker.{reference_not_found,permission_denied} seeded at zero (#717) and an INFO->WARN escalation once one reference has been unresolved for 30s. - SPIRE blocks inside its own cache subscription before the handler sends anything, so a reference that resolves to an entry whose SVID never lands leaves Recv blocked forever with no error, no log line and no retry. The first receive is synchronous (that is where NotFound/PermissionDenied arrive at all) and bounded by firstResponseTimeout, which turns that silent hang into an ordinary retry that also re-resolves the reference. Trust bundles needed rebuilding, because the Broker API has no node-wide bundle stream — SubscribeToX509Bundles also takes a workload reference, and a node with zero managed pods has none. Validation contexts are now DERIVED from two inputs: the agent's own Workload API bundle (available as soon as SPIRE attests the agent itself, strictly earlier than any pod's) and the union of the federated_bundles each live pod stream carries, dropped when that pod unsubscribes. #784's guarantees are unchanged and re-tested: single-writer monotonic publication under pushMu with the generation stamp, and never replacing a non-empty validation-context set with an empty one. The converter takes the Broker X509SVID, whose chain is ONE concatenated ASN.1 DER byte string (leaf first) rather than a repeated field — the boundaries are not given, so the chain must be parsed to be split, and a chain Envoy could not load is now rejected where the error names the SVID. Call sites, flags and chart: the CNI server passes namespace/name/UID instead of selectors (the UID was already in the ADD path and in storage); --spire-broker-socket replaces --spire-admin-socket (added to TestRetiredFlagsGone); spire.adminSocket.* becomes spire.brokerSocket.* pointing at /run/spire/agent/sockets/csi.spiffe.io/broker, where the spiffe/spire chart puts the socket directory on the node. The socket is mode 0770 owned by the spire-agent uid:gid, which the agent's existing runAsUser:0 + DAC_OVERRIDE already covers, so no securityContext change and the same read-only hostPath mount shape (verified on all five talos-main nodes under k8s-talos-main#79). Proposal 036 is corrected in one place while its Status moves to implemented: the access policy ships as an EXPLICIT permissive, never the chart's `auto`. The chart's broker-access-policy helper escalates `auto` to `enforced` for any allowed reference type other than WorkloadPIDReference — i.e. for the KubernetesObjectReference this design uses — and `enforced` needs an impersonation RBAC grant the chart only renders when the broker also sets impersonation.clusterWidePodsOnly. `auto` alone therefore fails CLOSED with PermissionDenied on every pod. Phasing item 3 now says the hardening step must flip both at once. Tests. A fake SPIFFE Broker Endpoint in common/spire/spiretest serves real mTLS from a test CA, rejects any call missing the security header with InvalidArgument, resolves references from a table and can return NotFound-then- success, PermissionDenied, an early stream close and federated bundles — so the bridge tests exercise the production client, a real UDS, a real handshake and the real interceptors rather than a stub. Every existing test is ported, none dropped: the push-ordering/S10/S11 suite (now driven through per-pod federated bundles, with certificate serials carrying the SVID generation because the converter parses the chain), the reconnect suite, the late-identity #740 test and the node-SVID converter tests. New: the security header and the full key+UID reference on every call, the server authorizer rejecting both a non-SPIRE-agent path and a foreign trust domain, NotFound retrying to success, the PermissionDenied counter, federated-bundle union add/remove, a zero-pod node still serving validation contexts, a rotation on a live stream, and the error classification table. A second flag-contract test mirrors //agent/internal/supervisorcmd for the agent DaemonSet: every --flag the chart passes must exist on the command. Without it a half-migrated chart is invisible until a rollout leaves every node's agent exiting on "unknown flag". e2e harnesses move from SPIRE chart 0.28.4 (SPIRE 1.14.5, no Broker API) to 0.30.2 with crds 0.6.1, drop authorizedDelegates + sockets.admin, and register the broker in both required blocks. Verification: bazel build //... //test/e2e:e2e_test; bazel test //... (106 tests, all pass); bazel test --config=race --runs_per_test=3 //agent/internal/spire/... //common/spire/... //agent/internal/cni/... ; //:format.check; --config=lint --@aspect_rules_lint//lint:fail_on_violation //... ; gazelle no churn; bazel mod tidy idempotent; scripts/go-deps-audit.sh OK after pruning spire-api-sdk's ten go.sum lines. Not verifiable without a live SPIRE >= 1.15.2: the on-wire interop itself. Validated on talos-main by the orchestrator. 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
…eep counters (#799) (#806) The identity bridge only had failure instruments, and handleSVIDUpdate logged at DEBUG, so a rotation — the most important thing the identity path does — left no trace in the agent. The 2026-09-19 8-hour soak had to infer four rotation cycles from Envoy's per-secret `envoy_sds_*_version` gauges, excluding every proxy-roll bucket by hand because a new Envoy changes every gauge once. - `aether.agent.spire.svid_updates{identity=pod|node, update=initial|rotated|unchanged}`: pod updates are classified per network namespace against the chain last served (forgotten on unsubscribe, so a rolling restart never reads as a rotation; `unchanged` is what a re-subscribe after a stream failure redelivers); the node SVID counts only on change, because the refresher polls. - `aether.agent.spire.bundle_updates{bundle=own|federated, update=initial|rotated}`: `own/rotated` is a trust-root change. - INFO lines `pod SVID rotated`, `node SVID rotated`, `Workload API trust bundle changed` — each rare by construction. - Every attribute set is seeded at zero (#717). Also seeds the attribute-less ghost-sweep counters and `identity.spiffe_id_override_rejected` at zero: two soaks running needed "no series = no prunes" reasoning about `orphans_pruned`, with the previous agent generation's value lingering through the staleness window after every roll. Tests: the fixture now installs its instruments before Start — the refresher records on the healthy path from its first pass, so installing them afterwards raced it under -race. Two assertions that expected an absent series now expect the seeded zero. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
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.
Found validating rev200 (#715) on talos-main:
sum by (k8s_node_name)(aether_agent_identity_inbound_binding_mismatch_total)returned no series — and so did the outbound counter from #686, which has been deployed for days. The OTel SDK only exports a counter after its firstAdd, and both counters are never incremented in the healthy case, so "0" and "never registered" were indistinguishable to the soak'sincrease(...[1h])grading queries.Fix:
Add(ctx, 0)on both counters at registration;TestCacheMetrics_IdentityCountersSeededAtZeropins that both are exported at zero before any increment. No behaviour change otherwise.Validation plan on talos-main: after deploy, both
aether_agent_identity_{inbound,outbound}_binding_mismatch_totalmust return five series reading 0.Refs #638, #686, #715.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr