Skip to content

fix(supervisor): retry base-id bind collisions in-process; bound proxy memory - #137

Merged
bpalermo merged 1 commit into
mainfrom
fix/supervisor-bind-collision-retry
Jun 11, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/supervisor-bind-collision-retry

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Closes out the 2026-06-11 worker-04 incident (proxy DS roll → ~165s node data-plane gap, reproduced live on the #135 deploy roll).

1. Bind-collision retry (the incident fix)

The two-sided failure:

  • Predecessor: its heartbeat is LIVE-gated — written only while its admin probe succeeds. Under node load the probes time out → heartbeat goes stale while its Envoy is alive and serving. When the pod is then deleted, the same failed probe routes it into awaitProtocolTermination (deliberately deadline-free), so it holds the base-id domain socket until the kubelet SIGKILL at grace 180s.
  • Successor: stale heartbeat → initStartEpoch declares "no live predecessor" → epoch 0 → unable to bind domain socket … errno=98 → exits within ms → supervisor exits non-zero → kubelet CrashLoopBackOff (10→20→40→80s). The stacked backoffs against the predecessor's grace drain are the outage.

Fix (successor side only — the predecessor's deadline-free wait stays, it's what prevents errno-111 aborts): a newest epoch that dies non-LIVE within 5s of launch in cross-pod mode is retried in-process every 3s: epoch detection re-runs from scratch (attach at E+1 if the predecessor becomes confirmable, epoch 0 once the socket frees). The predecessor keeps serving the whole time; the first attempt after it exits binds with ≤3s gap. Bounded at 90 attempts (exceeds the 180s grace, the latest possible resolution) so a genuinely broken Envoy still surfaces as a pod crash. New aether.supervisor.child_exits kind: bind_collision_retry.

Log fingerprint this replaces: "no live predecessor; starting fresh at epoch 0","statePresent":true + crash-loop.

2. Proxy container resources (was: fully unbounded)

The proxy DS shipped resources: {} — no requests, no limits. The connection-leak incident (#136) grew Envoy to 3.5 GiB and degraded the node (kubelet flap, agent informer desync, watchdog kills) rather than being contained. Defaults now: requests 500m/1Gi, memory limit 1Gi (an OOM kill is recoverable via hot restart; node starvation is not), no CPU limit (throttling the data plane converts contention into latency and failed health checks).

3. Netns filter-state sharing: TRANSITIVE → ONCE

The transport has been single-hop since #98 removed the HBONE tunnel; TRANSITIVE (re-propagation through further upstream hops) was #86-era plumbing for the two-layer tunnel path. ONCE scopes the source-pod netns to exactly the hop where the transport-socket matcher selects the client cert, so a future chained/internal hop can't silently inherit per-source cert selection. Validate per-pod XFCC URI SAN on talos after deploy (unit tests can't exercise Envoy's runtime sharing semantics).

Also adds client connection-shape guidance to workload-requirements.md (keepalive/H2 clients share one upstream mTLS conn across streams; connection-per-request is the expensive shape).

Testing

  • TestBindCollisionRetriedInProcess: stub Envoy exits 1 while a blocker file simulates the held socket — supervisor retries in-process without exiting, recovers when the blocker is removed, all attempts at epoch 0 (no climbing), clean nil exit.
  • TestNetnsFilterStateSharedOnce; chart template tests for the resources block.
  • Full suite: 38/38.

🤖 Generated with Claude Code

…y memory

Three related hardenings from the 2026-06-11 worker-04 incident (a proxy DS
roll cost a ~165s node data-plane gap):

1. Bind-collision retry. When the predecessor proxy's heartbeat goes stale
   (its LIVE-gated writes stop whenever its admin probes time out under
   node load) but its Envoy is still alive, initStartEpoch picks epoch 0
   and the fresh Envoy loses the base-id domain-socket bind race
   (errno 98), exiting within milliseconds. The supervisor previously
   exited non-zero, handing the retry to the kubelet's CrashLoopBackOff —
   whose 10..80s gaps, stacked against the predecessor draining out its
   180s termination grace in awaitProtocolTermination, produced the
   outage. A newest epoch that dies non-LIVE within 5s of launch in
   cross-pod mode is now retried in-process every 3s: epoch detection is
   re-run from scratch (attach at E+1 if the predecessor becomes
   confirmable, epoch 0 once the socket frees), the predecessor keeps
   serving throughout, and the first attempt after it exits binds with at
   most a 3s gap. Bounded at 90 attempts so a genuinely broken Envoy
   (bad bootstrap also dies fast) still surfaces as a pod crash. New
   child-exit metric kind: bind_collision_retry.

2. Proxy resources. The proxy container had no requests or limits at all:
   the connection-leak incident grew Envoy to 3.5 GiB and degraded the
   NODE (kubelet flap, agent informer desync) rather than being contained.
   Default now requests 500m/1Gi with a 1Gi memory limit (OOM kill is
   recoverable via hot restart; node starvation is not) and deliberately
   no CPU limit (throttling the data plane converts contention into
   latency and failed health checks).

3. Netns filter state sharing narrowed TRANSITIVE -> ONCE. The transport
   is single-hop since #98 removed the HBONE tunnel; ONCE scopes the
   source-pod netns to exactly the hop where the service cluster's
   transport-socket matcher selects the client certificate, so a future
   chained/internal hop cannot silently inherit per-source cert selection.

Also documents the client-side connection-shape guidance in
workload-requirements.md: per-downstream-connection pooling makes
keepalive/HTTP-2 clients cheap (multiplexed streams share one upstream
mTLS connection) and connection-per-request the expensive shape.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@bpalermo
bpalermo force-pushed the fix/supervisor-bind-collision-retry branch from e3245b6 to 408cb3b Compare June 11, 2026 12:13
@bpalermo
bpalermo merged commit 9af0626 into main Jun 11, 2026
10 checks passed
@bpalermo
bpalermo deleted the fix/supervisor-bind-collision-retry branch June 11, 2026 12:14
bpalermo added a commit that referenced this pull request Jun 11, 2026
* feat(proxy): overload manager with health-gateway bypass

Third layer of the memory-incident defense, after leak prevention
(#135/#136) and containment (#137's 1Gi limit): graceful degradation
before the limit's OOM kill. A fixed_heap monitor (default 768Mi = 75% of
the 1Gi container limit; heap excludes stats/code//dev/shm) drives a
shedding ladder:

  0.80 shrink_heap
  0.90 disable_http_keepalive          (sheds idle downstream conns; their
                                        per-downstream upstream pools then
                                        idle out via the 30s timeout)
  0.85-0.95 reduce_timeouts            (scales HTTP downstream idle toward
                                        2s - the dynamic version of #136)
  0.95 stop_accepting_requests         (503s new streams, which client
                                        routes retry on a DIFFERENT
                                        endpoint - the overloaded node
                                        sheds load to other replicas)
  0.98 stop_accepting_connections

The agent-generated health-gateway listener sets bypass_overload_manager:
delegated liveness must report APP truth, not proxy state. Without the
bypass an overloaded proxy would 503 the agent's liveness probes and flap
every local pod's registry health cluster-wide on transient overload;
shedding belongs to the data-plane listeners (503+retry, client active
HC), not the liveness channel. The gateway is a node-local UDS with a
handful of agent connections, so the exemption frees no meaningful
memory.

Inert in normal operation: steady-state heap sits far below the first
rung. Rendered bootstrap validated with `envoy --mode validate` against
the pinned image digest (configuration OK). Gated by
proxy.overload.enabled (default true).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(proxy): drive the overload ladder from cgroup_memory, not fixed_heap

The fixed_heap monitor measures tcmalloc heap, but the OOM killer enforces
the cgroup limit on the whole container working set — the supervisor
process, kernel socket buffers (charged to the cgroup, and correlated with
exactly the overload scenario) and thread stacks are all invisible to a
heap monitor, which forced a ~75% heap budget of guesswork and a values
knob that had to be bumped in lockstep with the memory limit.

The cgroup_memory monitor reads memory.current / memory.max directly, so
the thresholds sit against the real kill line and the knob disappears
(optional maxMemoryBytes only to engage the ladder below the cgroup
limit). Verified end-to-end against the pinned Envoy image: listed in the
binary's compiled-in resource monitors, --mode validate OK, and a live
run under docker --memory=256m reports pressure tracking the limit with
zero failed_updates.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant