You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Agent DaemonSet roll drops pre-existing pods' per-pod Envoy listeners (heals only on pod roll) #261
After a full agent DaemonSet roll (e.g. an agent upgrade), pre-existing (long-lived) pods lose their per-pod Envoy listeners — outbound 127.0.0.1:18081 (egress) and inbound :15008 — and stay broken until those pods are themselves rolled. Connectivity does not self-heal.
Reproduction (talos-main, 2026-06-22, during the 0.18.0 deploy)
Deploy a chart rev that rolls the agent DaemonSet (binary changed).
After the agents roll, test a 17h-old workload:
client → 127.0.0.1:18081 (node egress) → exit 7 / connection refused (the pod's egress listener is gone).
edge → backend pod (:15008) → 503 (the backend's inbound listener is gone).
Reproduced consistently across retries; backends themselves were 1/1 Running and healthy.
kubectl rollout restart deploy/{client,echo,svc-1,svc-2} → immediately healed (node-mesh 200 on the first try post-roll; edge path routing green).
Impact
An agent upgrade silently breaks mesh connectivity for every existing workload until each is rolled. That's a serious operational regression — agent rolls should be transparent to running pods.
Likely mechanism (to confirm)
On agent restart, LoadListenersFromStorage rebuilds the per-pod listeners from local storage and republishes the snapshot to the (still-running) node Envoy. Candidates for why pre-existing pods drop out:
A storage-reload gap (CachedLocalStorage rehydration missing pods at startup).
The republished snapshot being incomplete, so Envoy removes the absent per-pod listeners.
Related
Same class as the earlier prober connection_error degradation (a long-lived prober pod lost its egress listener; rolling healed it) — this is the clean, reproducible version, tied to agent rolls.
Root-caused — it's stale local storage, not proxy re-bind
Used the prober DaemonSet as a live canary (long-lived, not rolled by 0.18.0): after the roll it's at 100% connection_error. Inspected worker-01:
The agent at restart loaded count:8 pods and generated the full listener set (17) — no skipping pod with missing network namespace (netns-guard skips = 0). So the agent is NOT dropping listeners.
BUT it generated the prober listener for prober-vhbp8 (netns 834daf…) — yesterday's prober pod, long deleted. The live prober on this node is prober-k7vsm (1/1, 10.244.3.177), which is absent from the agent's storage entirely (0 references).
So the proxy bound outbound_http_prober-vhbp8 into the dead pod's netns; the live prober-k7vsm got no listener → 127.0.0.1:18081 refused → connection_error. Rolling the pod issues a fresh CNI ADD → heals.
Mechanism (two desyncs)
Missed CNI DEL for prober-vhbp8 → its storage file and its netns bind-mount pin (/run/aether/netns/834daf…) linger. os.Stat on the lingering pin succeeds, so netnsExists returns true and the fix(agent,proxy): prune stale-netns pods + supervisor crash-fast-fail #245 stale-netns guard/sweep does NOT prune it — the guard is fooled by a lingering pin (it checks netns presence, not pod presence).
Missed CNI ADD for the replacement prober-k7vsm → the live pod never entered storage.
The agent restart (0.18.0 roll) merely re-applied this already-stale storage; the desync predates the roll. Nothing reconciles local storage vs the node's actual pods — the ghost sweep reconciles registry endpoints vs storage, but storage is the corrupted source of truth here.
Fix direction
Reconcile the agent's local storage against the node's actual Kubernetes pods (by pod UID/name — the agent already queries node metadata), not against netns presence:
Prune storage entries whose pod no longer exists (regardless of a lingering netns pin) → drops the dead-netns listener.
Surface (and ideally recover) live pods missing from storage (missed ADD) — at minimum log/metric; full recovery needs the CNI data, so a pod-UID-keyed reconcile + re-request, or alerting for operator action.
agent/storage/local.go (CachedLocalStorage): one <containerID>.json file per pod, atomic writes, loadAll rehydrates the whole dir into the in-memory cache at Initialize. Sound — so a running pod missing from storage means its <containerID>.json is absent on disk (its CNI ADD never durably wrote, or the file was removed), and a ghost means a stale file lingers.
The two desync classes (both present on worker-01)
Missing live pod (prober-k7vsm): its file is absent → a missed/lost CNI ADD (or it was pruned and never re-added). The pod runs with no listener → connection_error, and never self-heals.
Why nothing fixes it today
The ghost sweep reconciles registry endpoints ↔ local storage, never local storage ↔ the node's actual pods. And the #245 prune trusts netnsExists, which a lingering bind-mount defeats (and which could conversely over-prune a live pod whose stored netns path went stale after a sandbox change).
Fix design (no new RBAC — the agent already has pods: list/get/watch + a k8sClient)
Extend sweepGhostEndpoints (or a sibling loop) to reconcile storage against the node's real pods:
List pods on this node (s.k8sClient.List, fieldSelector spec.nodeName=s.nodeName).
Prune ghosts by pod-existence: for each stored CNIPod, if no live pod matches its namespace/name, RemoveResource + RemovePod — regardless of netnsExists. This removes lingering-pin ghosts like vhbp8 (fixes the dead-netns listener + the segfault risk).
Surface missing ADDs: for each live mesh-managed pod (has IP, aether.io/managed) on the node with no matching stored entry, emit a metric + log + Event. The agent can't synthesize the CNI data (netns/IPs) to self-heal, so this is operator/auto-roll signal — but at least it's no longer silent.
Separately worth chasing for prevention: whyk7vsm's CNI ADD didn't durably land (lost write vs over-prune) — but the reconcile cures the desync class regardless, and the startup taint (separate PR) closes the cold-start window.
Prevention root cause: CNI DEL doesn't guarantee the storage delete (context-propagation + ordering)
AddPod and RemovePod are asymmetric, and the asymmetry produces ghosts:
AddPod (robust):
storage.AddResource is first (pod.go:74) — durable before anything fallible.
RegisterEndpoint failure is tolerated (pod.go:99-103: logs "reconciliation sweep will retry", no early return).
So once an ADD proceeds past the store, storage always has the pod.
RemovePod (the bug):
UnregisterEndpoints(unregCtx) (pod.go:182) runs on the request context and is fatal — on error it returns at line 186.
snapshotCache.RemovePod(xdsCtx) (198) is likewise fatal (returns at 202).
storage.RemoveResource (206) is last.
So if the request ctx is canceled (the plugin's delTimeout, kubelet cancel, or agent SIGTERM — common/xds/server.go GracefulStop falls back to a forced Stop() after ShutdownTimeout), or the registrar is briefly unavailable (we saw UnregisterEndpoints fail with context canceled during the registrar roll), the handler returns beforeRemoveResource → the storage file and its netns pin linger → exactly the prober-vhbp8 ghost (and a latent #245 dead-netns segfault). RemoveResource itself ignores ctx, but the handler never reaches it.
Fix (matches the asymmetry)
Make DEL mirror ADD — storage delete first / guaranteed, registry+listener best-effort:
In RemovePod, remove local storage first (or unconditionally, e.g. defer), on a detached/background context, so the durable local truth is cleared regardless of request-ctx cancellation or registrar availability.
Tolerate UnregisterEndpoints failure (log + continue, like ADD tolerates RegisterEndpoint) — the ghost sweep reconciles the registry endpoint; it must not abort the local delete.
Mind the lifecycleMu window (pod.go:174-177) when reordering — keep the liveness loop from resurrecting a half-removed pod.
This guarantees the storage delete on shutdown / cancellation / registrar churn, eliminating the ghost class at the source. The storage↔pods reconcile (prior comment) remains the cure for any residual desync (and the missing-ADD case); the startup taint closes the cold-start window. Three layers: guaranteed delete (prevention) + reconcile (cure) + taint (cold-start).
Resolved — prevention + cure shipped and validated on talos-main
Root cause: the agent's local storage desynced from reality — ghosts from missed CNI DELs whose netns pin lingered (so the #245 netns guard couldn't catch them → dead-netns listeners → connection_error + latent segfault), and missing pods from lost CNI ADDs (running pods with no listener, never self-healing).
The reconcile cleaned the real degraded state: 26 orphans pruned (incl. the root-caused prober-vhbp8, netns 834daf…) and 116 missed-ADDs surfaced (incl. prober-k7vsm). After healing rolls the sweep converged (0/0), the prober SLI returned to 100% success (was 100% connection_error), node-mesh + edge both 200, and a post-roll sweep showed 0 new orphans (confirming the guaranteed delete). New metrics ghost_sweep.orphans_pruned / ghost_sweep.missing_storage are flowing.
Closing as resolved. The cold-start prevention layer continues in #263.
Activity
bpalermo commentedon Jun 22, 2026
Root-caused — it's stale local storage, not proxy re-bind
Used the prober DaemonSet as a live canary (long-lived, not rolled by 0.18.0): after the roll it's at 100%
connection_error. Inspected worker-01:count:8pods and generated the full listener set (17) — noskipping pod with missing network namespace(netns-guard skips = 0). So the agent is NOT dropping listeners.prober-vhbp8(netns834daf…) — yesterday's prober pod, long deleted. The live prober on this node isprober-k7vsm(1/1,10.244.3.177), which is absent from the agent's storage entirely (0 references).outbound_http_prober-vhbp8into the dead pod's netns; the liveprober-k7vsmgot no listener →127.0.0.1:18081refused →connection_error. Rolling the pod issues a fresh CNI ADD → heals.Mechanism (two desyncs)
prober-vhbp8→ its storage file and its netns bind-mount pin (/run/aether/netns/834daf…) linger.os.Staton the lingering pin succeeds, sonetnsExistsreturns true and the fix(agent,proxy): prune stale-netns pods + supervisor crash-fast-fail #245 stale-netns guard/sweep does NOT prune it — the guard is fooled by a lingering pin (it checks netns presence, not pod presence).prober-k7vsm→ the live pod never entered storage.The agent restart (0.18.0 roll) merely re-applied this already-stale storage; the desync predates the roll. Nothing reconciles local storage vs the node's actual pods — the ghost sweep reconciles registry endpoints vs storage, but storage is the corrupted source of truth here.
Fix direction
Reconcile the agent's local storage against the node's actual Kubernetes pods (by pod UID/name — the agent already queries node metadata), not against netns presence:
netnsExists(fix(agent,proxy): prune stale-netns pods + supervisor crash-fast-fail #245), which a lingering bind-mount defeats.Files:
agent/internal/cni/server/ghostsweep.go(extend to a pod-existence reconcile),agent/internal/xds/cache/listener.go(#245 guard),agent/pkg/storage.bpalermo commentedon Jun 22, 2026
Storage-mechanism findings + concrete fix design
agent/storage/local.go(CachedLocalStorage): one<containerID>.jsonfile per pod, atomic writes,loadAllrehydrates the whole dir into the in-memory cache atInitialize. Sound — so a running pod missing from storage means its<containerID>.jsonis absent on disk (its CNI ADD never durably wrote, or the file was removed), and a ghost means a stale file lingers.The two desync classes (both present on worker-01)
prober-vhbp8): missed CNI DEL left both the storage file and the/run/aether/netns/834daf…bind-mount pin.netnsExists(os.Stat) succeeds on the lingering pin → the fix(agent,proxy): prune stale-netns pods + supervisor crash-fast-fail #245 stale-netns prune can't catch it (it keys on netns presence, not pod presence). The agent keeps emitting a listener bound to a dead netns (also a latent fix(agent,proxy): prune stale-netns pods + supervisor crash-fast-fail #245-segfault if that pin ever points at a truly-gone netns).prober-k7vsm): its file is absent → a missed/lost CNI ADD (or it was pruned and never re-added). The pod runs with no listener →connection_error, and never self-heals.Why nothing fixes it today
The ghost sweep reconciles registry endpoints ↔ local storage, never local storage ↔ the node's actual pods. And the #245 prune trusts
netnsExists, which a lingering bind-mount defeats (and which could conversely over-prune a live pod whose stored netns path went stale after a sandbox change).Fix design (no new RBAC — the agent already has
pods: list/get/watch+ a k8sClient)Extend
sweepGhostEndpoints(or a sibling loop) to reconcile storage against the node's real pods:s.k8sClient.List, fieldSelectorspec.nodeName=s.nodeName).CNIPod, if no live pod matches itsnamespace/name,RemoveResource+RemovePod— regardless ofnetnsExists. This removes lingering-pin ghosts likevhbp8(fixes the dead-netns listener + the segfault risk).aether.io/managed) on the node with no matching stored entry, emit a metric + log + Event. The agent can't synthesize the CNI data (netns/IPs) to self-heal, so this is operator/auto-roll signal — but at least it's no longer silent.Separately worth chasing for prevention: why
k7vsm's CNI ADD didn't durably land (lost write vs over-prune) — but the reconcile cures the desync class regardless, and the startup taint (separate PR) closes the cold-start window.bpalermo commentedon Jun 22, 2026
Prevention root cause: CNI DEL doesn't guarantee the storage delete (context-propagation + ordering)
AddPodandRemovePodare asymmetric, and the asymmetry produces ghosts:AddPod(robust):storage.AddResourceis first (pod.go:74) — durable before anything fallible.RegisterEndpointfailure is tolerated (pod.go:99-103: logs "reconciliation sweep will retry", no early return).RemovePod(the bug):UnregisterEndpoints(unregCtx)(pod.go:182) runs on the request context and is fatal — on error itreturns at line 186.snapshotCache.RemovePod(xdsCtx)(198) is likewise fatal (returns at 202).storage.RemoveResource(206) is last.So if the request ctx is canceled (the plugin's
delTimeout, kubelet cancel, or agent SIGTERM —common/xds/server.goGracefulStop falls back to a forcedStop()afterShutdownTimeout), or the registrar is briefly unavailable (we sawUnregisterEndpointsfail withcontext canceledduring the registrar roll), the handler returns beforeRemoveResource→ the storage file and its netns pin linger → exactly theprober-vhbp8ghost (and a latent #245 dead-netns segfault).RemoveResourceitself ignores ctx, but the handler never reaches it.Fix (matches the asymmetry)
Make DEL mirror ADD — storage delete first / guaranteed, registry+listener best-effort:
RemovePod, remove local storage first (or unconditionally, e.g.defer), on a detached/background context, so the durable local truth is cleared regardless of request-ctx cancellation or registrar availability.UnregisterEndpointsfailure (log + continue, like ADD toleratesRegisterEndpoint) — the ghost sweep reconciles the registry endpoint; it must not abort the local delete.lifecycleMuwindow (pod.go:174-177) when reordering — keep the liveness loop from resurrecting a half-removed pod.This guarantees the storage delete on shutdown / cancellation / registrar churn, eliminating the ghost class at the source. The storage↔pods reconcile (prior comment) remains the cure for any residual desync (and the missing-ADD case); the startup taint closes the cold-start window. Three layers: guaranteed delete (prevention) + reconcile (cure) + taint (cold-start).
fix(cni): guarantee the local storage delete on CNI DEL (issue #261) (#…
feat(cni): reconcile local storage against the node's actual pods (is…
bpalermo commentedon Jun 22, 2026
Resolved — prevention + cure shipped and validated on talos-main
Root cause: the agent's local storage desynced from reality — ghosts from missed CNI DELs whose netns pin lingered (so the #245 netns guard couldn't catch them → dead-netns listeners →
connection_error+ latent segfault), and missing pods from lost CNI ADDs (running pods with no listener, never self-healing).Three layers:
RemovePodguarantees the storage delete (detached ctx, storage-first, best-effort/bounded unregister), so a canceled ctx / SIGTERM / rolling registrar can't leave a ghost.e2e on talos-main (rev 22,
0.18.0-44bc8dd)The reconcile cleaned the real degraded state: 26 orphans pruned (incl. the root-caused
prober-vhbp8, netns834daf…) and 116 missed-ADDs surfaced (incl.prober-k7vsm). After healing rolls the sweep converged (0/0), the prober SLI returned to 100% success (was 100%connection_error), node-mesh + edge both 200, and a post-roll sweep showed 0 new orphans (confirming the guaranteed delete). New metricsghost_sweep.orphans_pruned/ghost_sweep.missing_storageare flowing.Closing as resolved. The cold-start prevention layer continues in #263.
feat(agent): Cilium-style startup taint to gate pods on CNI readiness (…