Skip to content

feat(proxy): overload manager with health-gateway bypass - #138

Merged
bpalermo merged 2 commits into
mainfrom
feat/proxy-overload-manager
Jun 11, 2026
Merged

bpalermo merged 2 commits into
mainfrom
feat/proxy-overload-manager

Conversation

@bpalermo

@bpalermo bpalermo commented Jun 11, 2026 •

Copy link
Copy Markdown
Owner

Third layer of the memory-incident defense: prevention (#135/#136) → containment (#137's 1Gi limit) → graceful degradation (this PR). Today, hitting the limit means a kernel OOM SIGKILL — abrupt epoch loss and a node blip. This engages a shedding ladder well before that.

Monitor: cgroup_memory (updated from fixed_heap after review discussion)

The monitor reads memory.current / memory.max from the container's own cgroup (v2 — talos), so pressure is measured against the real kill line: it sees everything the OOM killer sees (tcmalloc heap, the supervisor process sharing the container, kernel socket buffers — which are charged to the cgroup and correlate with exactly the overload scenario). No heap-to-RSS ratio guesswork, no values knob to bump in lockstep with the memory limit; optional proxy.overload.maxMemoryBytes only to engage the ladder below the cgroup limit.

Empirically verified against the pinned Envoy image (1.38 digest): listed in the binary's compiled-in resource monitors, --mode validate OK on the rendered bootstrap, and a live run under docker --memory=256m reports cgroup_memory.pressure tracking the limit with failed_updates: 0.

The ladder

Pressure Action Fit
0.80 shrink_heap release tcmalloc pages
0.90 disable_http_keepalive sheds idle downstream conns → their per-downstream upstream pools idle out via #136's 30s timeout — the exact resource class that blew up
0.85→0.95 reduce_timeouts (HTTP downstream idle scaled toward 2s) the dynamic version of #136's static timeouts
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 last resort before OOM

Health-gateway bypass_overload_manager

Delegated liveness must report app truth, not proxy state. Without the bypass, an overloaded proxy 503s the agent's liveness probes → the agent marks every local pod unhealthy → registry health flaps cluster-wide on transient overload, plus a slow re-promotion round on recovery. Shedding belongs to the data-plane listeners (503+retry, client active HC against the inbound listener), not the liveness channel. The gateway is a node-local UDS with a handful of agent connections, so the exemption frees no meaningful memory.

Trade accepted: under prolonged overload, eds-mode endpoints stay in rotation and each request pays one failed attempt + retry, instead of leaving rotation entirely — strictly better than health-flapping the registry on brief overload.

Notes

  • Inert in normal operation: post-fix(agent): bound idle connections and per-connection buffers #136 steady-state RSS (~70–150Mi measured in the latest e2e) sits far below the 0.80 rung of 1Gi.
  • Supervisor unaffected: admin runs on the main thread outside overload actions, so /server_info watchdogs keep working.
  • CPU overload deliberately out of scope: CONTAINER mode needs a cpu quota (we intentionally set none — throttling a data plane is worse), HOST mode would shed on co-tenant noise.

Testing

  • TestHealthGatewayBypassesOverloadManager; chart lint + template tests; full suite 38/38.
  • Rendered bootstrap validated against the pinned image digest (configuration OK) + live cgroup-pressure smoke test.
  • Post-deploy validation: overload.envoy.resource_monitors.cgroup_memory.pressure reflects RSS/1Gi, failed_updates 0, all overload_actions.*.active 0 in steady state.

🤖 Generated with Claude Code

bpalermo and others added 2 commits June 11, 2026 09:25
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]>
…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]>
@bpalermo
bpalermo merged commit 866b1a8 into main Jun 11, 2026
10 checks passed
@bpalermo
bpalermo deleted the feat/proxy-overload-manager branch June 11, 2026 12:46
bpalermo added a commit that referenced this pull request Jun 11, 2026
… 512Mi (#139)

* fix(proxy): overload manager back to fixed_heap — cgroup_memory is fatal in privileged pods

Deploying #138 (rev 64) took the entire data plane down for ~13 minutes:
every proxy aborted at bootstrap with "No supported cgroup memory
implementation found" and crash-looped until the overload manager was
disabled via values (rev 65).

Root cause: the cgroup_memory monitor reads
/sys/fs/cgroup/memory.{current,max}. That works under docker — private
cgroup namespace, the container sees its own leaf cgroup, which is where
the pre-merge validation passed — but the aether-proxy DaemonSet is a
PRIVILEGED pod and gets the HOST cgroup namespace: /sys/fs/cgroup is the
host root cgroup, which has no memory.max. Envoy treats the failed probe
as a fatal bootstrap error.

The outage was cluster-wide rather than canaried because the supervisors
watch the bootstrap config (fsnotify) and hot-restarted every node into
the poisoned ConfigMap at once, bypassing the DaemonSet rollout safety
entirely. A follow-up hardening (supervisor pre-validates new bootstrap
config with `envoy --mode validate` on the node before hot-restarting,
keeping the old config serving on failure) is planned separately — node-
local validation WOULD have caught this, unlike the docker-side check.

fixed_heap is tcmalloc-internal (no cgroup access), so its validation is
environment-independent. The 768Mi = 75%-of-limit budget and its
rationale are restored, and the ConfigMap now documents exactly why
cgroup_memory must not be reintroduced while the proxy is privileged.

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

* feat(proxy): default proxy memory limit 512Mi

Steady-state proxy RSS measured 67-148Mi post-#136 (e2e 2026-06-11), so
512Mi keeps ~3.5x headroom while halving the node memory reservation
(request == limit, Guaranteed) and engaging the overload ladder earlier
on a real leak. Heap budget scales with it: 384Mi = 75% of the limit
(top rung 0.98x384 ~= 376Mi + non-heap extras stays under the cgroup
kill line).

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