Skip to content

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

Closed

Description

@bpalermo

Found by the rev214 deploy validation (2026-09-16). worker-03 ran 12 m 47 s without an aether-agent during the helm upgrade; the data path on the node never broke (proxy kept serving, prober 0 errors), but the node was unmanaged for that whole time and three alerts fired.

Chain: worker-03 sat at 89 % CPU requests (a tenant workload, clj-grpc-soak/grpc-jvm, requests 1 full core) → the aether-edge Deployment's maxSurge: 1 placed a third edge pod there → the system-node-critical aether-proxy DaemonSet pod preempted it → the evicted edge pod's CNI DEL failed 42× because /run/aether/cni.sock was gone with the old agent pod → a Pod stuck in Terminating still counts its CPU request → the new aether-agent pod could not be scheduled to restore the socket. Circular; broken by force-deleting the wedged edge pod (all three pods scheduled 5 s later). The precondition is still live (84 % after the tenant left some load), so this recurs on the next deploy.

Three independent fixes, any one of which breaks the loop:

  1. CNI DEL must not depend on the agent socket being up: when the socket is absent, the plugin should succeed the DEL locally (remove the netns/redirect state it owns, leave a tombstone the agent's ghost sweep already knows how to reconcile — fix(agent,proxy): prune stale-netns pods + supervisor crash-fast-fail #245/fix(agent): self-heal pods left unmeshed by the reboot CNI boot race #641 machinery) instead of failing; a failed DEL keeps the pod Terminating forever, which is strictly worse than a stale registration.
  2. Edge rollout should not surge onto a node that cannot hold it: maxSurge: 0, maxUnavailable: 1 for the edge (it has 2 replicas and MetalLB fronts them), or a topologySpreadConstraint/anti-affinity that keeps the surge pod off nodes with an aether-proxy pending preemption.
  3. Agent priority: the agent DS should carry the same system-node-critical priority as the proxy so it can preempt what blocks it (today the proxy can, the agent cannot).

Also: the deploy brief's "cluster is quiet" premise was wrong — check kubectl top nodes / requests before rolling.

Refs #772, #245, #641.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Activity

  1. added
    bug
    on Sep 16, 2026
  2. bpalermo commented on Sep 16, 2026

    @bpalermo
    OwnerAuthor

    Elaboration and two corrections (2026-09-16)

    Correction 1 — fix option 3 is wrong. The agent DaemonSet already carries priorityClassName: system-node-critical (charts/aether/templates/agent-daemonset.yaml:24), the same as the proxy and mesh-dns. The agent could not preempt because the scheduler refuses to preempt on a node that has a terminating pod: preemption: not eligible due to a terminating pod on the nominated node. A Terminating pod keeps its CPU request until its sandbox is torn down, and the sandbox cannot be torn down because the CNI DEL keeps failing. Priority cannot break that loop; only completing (or bypassing) the DEL can.

    Correction 2 — fix option 1 must keep the netns pin. cni/internal/plugin/plugin.go:234-239 (CmdDel) returns the DEL error on purpose when sendRemovePod fails: "Keep the netns pin: the agent has not confirmed the pod's xDS resources are gone, and unpinning now reintroduces the deleted-netns" SIGSEGV (#112/#245 — Envoy still has listeners bound in that netns until the agent removes the pod's xDS resources). So "succeed the DEL locally and unpin" would reintroduce a worse bug. The right shape is narrower:

    • Distinguish agent absent (dial unix /run/aether/cni.sock: no such file or directory, ENOENT — the agent pod is gone) from agent refusing/erroring (socket present, RPC fails). Today both return the error; only the second one should.
    • On ENOENT: do not unpin, do not spawn the detached unpinner, write a tombstone next to the pin (e.g. <pin>.deleted with pod/ns/containerID/time), log at WARN, and return success so the runtime can finish the sandbox teardown and the pod releases its CPU request. The pinned netns keeps Envoy safe exactly as the current code intends.
    • On the next agent start: the agent already loads the previous generation's pod table from its hostPath storage and its ghost sweep (agent/internal/cni/server/ghostsweep.go, "an endpoint whose deregistration was lost (agent down at CNI DEL)") reconciles pods that no longer exist on the node — extend that path to also consume the tombstones: remove the pod's xDS resources, then remove the pin (the same delayed unpin the normal DEL path uses) and the tombstone. CNI GC (CmdGC) already unpins orphans as a backstop.
    • Bound the DEL's wait: even when the socket exists, a DEL that has been failing for longer than N minutes (containerd retries it indefinitely) should degrade to the same tombstone path rather than pinning the node forever.

    Mechanism recap with the measured numbers (rev214 deploy): worker-03 at 3,545 m of 3,950 m allocatable (89 %; clj-grpc-soak/grpc-jvm 1 core, tempo 750 m, otel-collector 300 m) → edge rollout maxSurge: 1, maxUnavailable: 0 (edge-deployment.yaml:17-21) places a third edge pod (400 m) on w03 → the system-node-critical proxy DS pod preempts it → its containers exit 0 at 02:38:59 but KillPodSandbox fails 42× over 11 min on the CNI DEL because the old agent pod was already gone → the Terminating pod holds 400 m → agent/mesh-dns/proxy replacements 0/6 nodes are available: 1 Insufficient cpu → node unmanaged 12 m 47 s (ADS stream lost, mesh-DNS snapshot frozen, three alerts). Data path never broke thanks to #578 and the demand-scoped snapshot. Broken by force-deleting the edge pod; recovery in 5 s. Did not recur on the rev215 roll only because the surge pod landed on w04/w02; w03 is still at 84 %.

    Plan, in order of leverage:

    1. CNI DEL tombstone path as above (robustness; removes the loop regardless of scheduling) — plugin change + agent ghost-sweep/GC change + tests with a fake absent socket; validate on talos by deleting the agent pod on one node and then deleting an app pod there (DEL must succeed, pin kept, tombstone consumed once the agent returns, no stale-netns crash, aether_agent_storage_stale_pods back to 0).
    2. Edge rollout maxSurge: 0, maxUnavailable: 1 (2 replicas behind MetalLB; a one-replica window is acceptable and avoids placing a third pod on a full node), or a topologySpreadConstraint — chart bump.
    3. Operational: the deploy brief must check node CPU requests before rolling; a kubectl top nodes/requests pre-flight in the validation runbook.
  3. bpalermo commented on Sep 16, 2026

    @bpalermo
    OwnerAuthor

    Update — the netns-pin ACK requirement can be relaxed. The crash the pin protects against is the upstream dial into a vanished netns (createClientConnection returning nullptr, dereferenced in HostImplBase::createConnection) — exactly what envoyproxy/envoy#45975 fixed (merged 2026-07-13, 39dfe6b3): it now surfaces as a FailedToCreateConnection pool failure / LocalConnectionFailure, i.e. a clean UF for that request. Our pinned proxy snapshot 1.40.0-dev.20260904.13144fb is 635 commits past that commit, so the fix is already deployed on talos-main (since rev203). The companion #45976 (opt-in netns validation at config load, merged 2026-08-27) is also in the snapshot but must stay OFF for us: it would turn a stale pod into an LDS/CDS NACK, which is worse than a clean dial failure.

    Revised fix 1 (simpler than the tombstone): in CmdDel, when sendRemovePod fails because the agent is unreachable, log at WARN, skip the readiness-probe wait, still spawn the normal detached unpinner with the existing NetnsUnpinDelay (60 s — cheap insurance for a hot-restart successor re-creating listeners and for deferred dials), and return success so the sandbox teardown completes and the Terminating pod releases its CPU. The agent side already self-heals the rest: LoadListenersFromStorage skips missing-netns pods at startup and the ghost sweep prunes them (#245, "agent down at CNI DEL" is its documented case). Update the stale comments in cni/internal/plugin/netnspin.go, plugin.go:234-239 and cni/config/config.go:39,115 that still describe the segfault as current behaviour. Keep the supervisor's crash budget (#245) as the last line of defence.

    Still to verify before merging: the listener side — a hot-restart successor asked to bind a per-pod listener into a netns that is already gone. Envoy's createListenSocket returns StatusOr, so the expectation is a rejected listener (LDS NACK for that update), not a crash; confirm on talos by unpinning a test pod early during a proxy roll and watching envoy_listener_manager_lds_update_rejected, the supervisor crash counters and the prober.

  4. bpalermo commented on Sep 16, 2026

    @bpalermo
    OwnerAuthor

    Addendum: envoyproxy/envoy#46503 (merged 2026-08-11, 86a5f9eb, 315 commits before our pinned snapshot) closes the second crash site the pin covered — the active health checkers (TCP/HTTP/gRPC) create upstream connections directly, so a stale-netns host crashed them even after #45975; they now record a NETWORK health-check failure instead. That is the "cold-start health checkers dial immediately → proxy unbootable" case from #245 and the ~13 s post-removal dial window that sized NetnsUnpinDelay. With #45975 + #46503 both deployed, a stale per-pod cluster costs at most one failed request and an unhealthy host until the agent prunes it; nothing on the upstream side can take the node proxy down. The only netns path not covered by the three PRs is listener creation into a vanished netns (hot-restart successor), which is expected to be a rejected listener, not a crash — still the one thing to confirm on talos before merging the relaxed DEL.

  5. bpalermo commented on Sep 16, 2026

    @bpalermo
    OwnerAuthor

    Listener-side verified on the exact pinned Envoy binary (1.40.0-dev from the aether-proxy image at 733802b / source 13144fb), file-based LDS, local rig (report kept with the session):

    case result
    A: LDS listener with a netns path that never existed rejected, not crashed — lds.update_rejected +1, listener_create_failure +1, manager not wedged (next valid update accepted); pushing the bad config over a live listener leaves the old listener serving
    B: netns alive at creation, then unmounted/removed listener keeps working (socket holds the netns); an in-place LDS modify of it is accepted (socket duplicated, path never reopened)
    B5: remove + re-add with the stale path rejected, not crashed
    C: hot restart, netns alive socket inherited, traffic uninterrupted
    C4: hot restart, netns path gone rejected, not crashed — but the successor NACKs the whole SotW LDS response and comes up with zero listeners; the port dies when the parent finishes parent_shutdown_time

    Why it cannot crash: Utility::execInNetworkNamespace (source/common/network/utility.h:392-421) returns absl::InternalError on both the open() and setns() legs; the only RELEASE_ASSERT is the restore leg (unreachable for a root proxy in the init userns). The status flows through createListenSocketFactory (listener_manager_impl.cc:1340-1378) which logs, bumps listener_create_failure, and is itself wrapped in TRY_ASSERT_MAIN_THREAD.

    Why C4 loses the listener: the netns jump wraps the entire socket-creation body including the parent handoff — listener_manager_impl.cc:287-320 runs createListenSocketInternal() inside execInNetworkNamespace, and duplicateParentListenSocket(addr, worker, netns) sits at :375-381 inside it — so when the path is gone the successor never asks the parent for the (still valid) fd. Possible upstream improvement: attempt the parent-fd duplication before entering the namespace.

    Consequence for this fix: the agent must keep a stale-netns pod out of every snapshot, not only at storage load — otherwise a proxy hot restart inside the ≤60 s window between unpin and the next ghost sweep drops all listeners on the node. Added to the PR scope: per-generation netnsExists skip in the listener builders + aether_agent_snapshot_stale_netns_skipped_total. Alerting: envoy_listener_manager_lds_update_rejected / listener_create_failure and the failed to open netns file log line are the signals.

  6. bpalermo commented on Sep 16, 2026

    @bpalermo
    OwnerAuthor

    Validated on talos-main — rev216 / 0.92.23-0459c2a4 — PASS, with two corrections to how this should be graded

    Deployed 2026-09-16 13:29:01Z (helm rev 216, appVersion 0459c2a474df285cd80c28eabd5952b98140f4ef asserted; #791's proxy rebuild rode along, all 7 images rolled including cni-install 4de7d4e0… → 867a5559…, verified exit 0 on all five nodes). Full record: validate-rev216.md.

    The fix works

    CNI DEL issued while the node agent is genuinely gone now returns success and the sandbox tears down, instead of wedging forever:

    test node app pod delete → gone replacement agent state at that moment
    step 2 w05 4.17 s Pending
    step 3 w02 5.29 s starting

    No FailedKillPod, no KillPodSandbox failure, no failed to remove pod from agent event in either test. The agent really was unreachable — proven by the replacement pod's sandbox ADD failing in the same window with the exact ENOENT the fix classifies:

    Warning FailedCreatePodSandBox pod/svc-3-79c5b9bdf5-jf2bh
    ... plugin type="aether-cni" name="aether" failed (add): failed to add pod to agent:
    failed after 3 attempts: rpc error: code = Unavailable desc = connection error:
    desc = "transport: Error while dialing: dial unix /run/aether/cni.sock: connect: no such file or directory"
    

    Replacement agents came Ready normally (~18 s). The loop did not form, on the roll or in either test.

    Correction 1 — the path that actually fires is orphans_pruned, not stale_pruned / stale_netns_skipped

    The agent returns in ~5 s, far inside the 60 s NetnsUnpinDelay, so the netns pin is still valid and the entry is classified orphaned, not stale (applyPrune / pruneOnePod, ghostsweep.go:745-812). Reconciliation lands ~3.4 s after the agent returns:

    13:39:08.528 INFO server/ghostsweep.go:799
      ghost sweep: pruned orphaned pod (Kubernetes pod gone; CNI DEL missed, netns pin lingered)
      pod=svc-3-79c5b9bdf5-8k8kl netns=/run/aether/netns/41aeb9d436bb6e...
    13:39:08.735 INFO server/ghostsweep.go:1123
      ghost sweep: deregistered ghost endpoint service=aether-test/svc-3 ip=10.244.2.248
    

    Measured, both test nodes: ghost_sweep_orphans_pruned_total = 1, ghost_sweep_ghosts_removed_total = 2, storage_stale_pods = 0, and snapshot_stale_netns_skipped_total = 0.

    So the new per-generation stale-netns guard is deployed and seeded but was never exercised on-cluster. Step 3 proved the outcome it protects by a different route (below), but to exercise the guard itself the agent has to stay down longer than 60 s so the unpin beats the sweep. That is the largest gap in this validation and is worth a follow-up run.

    Correction 2 — aether_agent_ghost_sweep_stale_pruned_total is not seeded

    agent/internal/cni/server/metrics.go:175 guards the add:

    if stalePruned > 0 {
        m.stalePruned.Add(ctx, int64(stalePruned))
    }

    It is never registered at zero, so it does not exist in Prometheus until a real stale prune happens — same for the rest of the ghost_sweep_*_total family (only the gauges prune_breaker_engaged / unmeshed_pods are always present). This PR seeded the new counter correctly (snapshot_stale_netns_skipped_total = 0 on all 5 nodes + both edge pods ✓) but not the ghost-sweep family. "No series" is that counter's real baseline, so its first appearance ≥ 1 is itself the signal — it must not be graded as "0 = healthy". Seeding it would make the runbook's advice consistent.

    Step 3 — proxy hot restart inside the window: no listener loss

    Agent deleted, app pod deleted --grace-period=0, proxy deleted 0.16 s later to force a hot restart. The successor behaved exactly as the Envoy experiment predicted:

    13:43:44.809 live predecessor confirmed; starting cross-pod hot restart predecessorEpoch=9 startEpoch=10
    13:43:45.140 [config] loading 0 listener(s)        <- no xDS at all: the agent is down
    13:43:50.923 [upstream] lds: add/update listener 'outbound_http_echo-78779ffdc5-z5w78'  ... (first LDS)
    

    The stale pod never reached Envoy — the sweep pruned it at 13:43:49.406, 1.5 s before the first LDS push:

    • successor took the full 22-listener set (7 pods × capture/inbound/outbound_http + health_gateway)
    • the deleted pod svc-2-869987c55-j9cht: 0 occurrences anywhere in the successor's log
    • lds_update_rejected never incremented; lds_update_success = 4; update_failure = 1 (the stream failure while the agent was down, not a NACK)
    • 0 NACK / [error] / [critical] / [warning] / listener_create_failure / failed to open netns file
    • 0 prober errors on w02 — the predecessor (epoch 9) kept serving throughout the successor's warm-up, so the data path never gapped

    Roll and SLI

    Roll 3 m 00 s (rev215 5 m 08 s; rev214 15 m 20 s, of which 12 m 47 s was this bug). 5/5 cross-pod hot restarts v11.120; mesh-dns lame duck 1/node all reason=successor. 0 restarts, 0 taints, 0 ERROR lines anywhere, 0 alerts fired (#alerts silent since the rev214 resolve at 03:07:55Z; only pending EnvoyControlPlaneDisconnected / MeshDNSWatcherInactive, absorbed).

    SLI over 13:28:30Z → 13:55:46Z (27 m 16 s), covering the upgrade, the roll, all three destructive tests and 10 min of steady state:

    • liveness 0 / 41,100 = 0.000 %
    • mesh_dns 0 / 82,200 = 0.000 %, all dns_* zero on both the authoritative and the kube-dns-forwarded target
    • 5.02 /s per node per tier vs a nominal 5 /s; collector refused 0/0, export-failed byte-identical, RSS 264/261 MiB against the 1,126 MiB soft threshold — the SLI was never blind

    Steady state: a 10 m 00 s kubectl get pods -w emitted not one state change.

    This issue is not fully closed

    The fix removes the deadlock, not the trigger, and the precondition has widened since rev215:

    node CPU requests % allocatable
    main-worker-03 3345 m 84 %
    main-worker-04 3185 m 80 % (was 67 %)

    Two nodes now sit under 800 m of headroom against a 400 m edge surge pod. The surge replica landed on w05 this roll — luck, again. Plan items 2 (edge maxSurge: 0 or a topology spread) and 3 (the CPU-requests pre-flight in the deploy runbook) remain open, and are now the only thing standing between a full node and another preemption — which will no longer deadlock, but will still evict.

    Method notes / not observable

    • The app pod's grace period, not the delete instant, decides when the CNI DEL fires. My first attempt used a default 30 s-grace pod; the DEL landed ~8 s after the replacement agent was already serving and took the normal path, proving nothing. The agent-down window is only ~8 s. Any future runbook must use --grace-period=0.
    • The plugin's own WARN agent unreachable at CNI DEL was not reachable. The plugin is a short-lived process invoked by containerd; its stderr goes to the node's containerd log, not VictoriaLogs (control-tested: "pruned orphaned pod" returns the agent line with service.version=0459c2a4…, so the datasource and syntax are good). kubectl exec was denied. The behaviour is established indirectly and unambiguously by the pod state plus the ADD-side ENOENT event.
    • The <pin>.delfail marker and the netns_del_give_up_after_seconds bound were not exercised — both belong to the live-but-erroring agent branch; both tests used an absent agent. Covered only by the unit tests. cni-install correctly does not write the key (per docs/configuration.md), so the in-binary 5 m default applies.
    • The netns pin unlink itself (60 s mark) is not observable without node access; the listener drop is (the prune line above).
    • No load, no churn, no k6 — this is prober-only rate. http_req_failed not measured; the 8 h soak on this build has not been run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions