Skip to content

fix(proxy): pass --skip-hot-restart-parent-stats so the hot-restart child never blocks on the parent's main thread (#1050); hotrestart-wedge harness + soak gates - #1056

Merged
bpalermo merged 4 commits into
mainfrom
fix/1050-skip-hot-restart-parent-stats
Sep 28, 2026

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Root cause

Full analysis: #1050 (comment)

On rev248 one proxy roll in ~60 wedged both Envoy epochs until the supervisor's liveness watchdog killed them. The two main threads deadlock over the hot-restart domain sockets:

  • Parent → child UDP forward. After the child's DrainListeners RPC, every QUIC/UDP datagram the parent's workers read that no parent session owns is posted to the parent's main thread and sent to the child with a blocking, timeout-less sendmsg (hot_restarting_parent.cc:60-85, hot_restarting_base.cc:84-143). The child's UDP listeners stay paused until the parent exits, so for the whole --parent-shutdown-time-s window every packet of every new QUIC connection takes this path.
  • Child → parent stats. On every 5 s stats flush the child calls getParentStats, a blocking, timeout-less recvmsg (hot_restarting_child.cc:161-176).
  • When ~24 forwarded datagrams fill the child's queue just as it enters that recvmsg, the parent is parked in sendmsg and never reads the stats request. Admin, xDS and timers stop on both processes, and SIGTERM (a main-dispatcher event) cannot land on either.

The fix: --skip-hot-restart-parent-stats, on by default

  • New chart knob proxy.hotRestart.skipParentStats (default true) renders --envoy-arg=--skip-hot-restart-parent-stats through the supervisor's existing extra-args path (buildEnvoyCmd, which also feeds envoy --mode validate). The child then never makes the blocking stats call, so its half of the deadlock is gone.
  • The flag exists at the pinned Envoy 726d7ac (source/server/options_impl.cc:85, a TCLAP SwitchArg, read in stripped_main_base.cc:125/142). agent/internal/xds/proxy and //test/envoy_validate don't need to know about it: it is a command-line option, not bootstrap. //agent/internal/supervisorcmd:TestFlagsCoverTheChartContract still passes (the supervisor-side flag is --envoy-arg).
  • Cost: the parent's gauges and its last ≤5 s of counter deltas are not merged into the child. Counters are already per generation (aether_requests_total resets to ~0 on every proxy hot restart — counter values are not carried parent→child (labels are, since #707) #708), so increase()/rate() dashboards don't change.
  • Chart 1.0.3 → 1.0.4.
  • Tests: aether_proxy_skip_parent_stats_test checks the arg renders by default. aether_proxy_skip_parent_stats_off_test renders with the knob false and checks that the --service-zone value line is followed directly by env:. rules_helm can only assert that a pattern is present, so absence is pinned by position.

Harness: e2e/hotrestart-wedge.sh (from spike/1050-hotrestart-wedge-repro, tidied)

This is the kind leg that reproduced the wedge with symbolized stacks. Changes from the spike:

  • WEDGE_SKIP_PARENT_STATS (applied at up through the new HR_SKIP_PARENT_STATS in eastwest-quic-hotrestart.sh).
  • run now reports SKIP_PARENT_STATS= read from the live Envoy argv.
  • The header explains what the leg proves.
  • Fixed a self-match: the node-side sh -c carried the *envoy* pattern in its own argv. The first red run therefore reported yes on a cluster without the flag.
  • After each wedge, run waits for the proxy to come back instead of sleeping a fixed 60 s. Each recovery is a container restart, so kubelet's crash-loop backoff grows with every wedge, and a fixed sleep aborted the run.

Both arms ran on kind: eastwest-quic bring-up, 17 h3 inbound listeners, 24 loops × 20 rps per (source, h3 destination), SIGHUP hot restarts, WEDGE_FREEZE_S=6.

Red: knob false. Every restart wedged. Kernel stacks: parent main thread in unix_dgram_sendmsg, child main thread in __unix_dgram_recvmsg, the same as in production.

  envoy --skip-hot-restart-parent-stats: no
  ✗ restart 1 (epoch 0 -> ?): WEDGE      recovered after ~112s (epoch 0)
  ✗ restart 2 (epoch 0 -> ?): WEDGE      recovered after ~198s (epoch 0)
  ✗ restart 3 (epoch 0 -> ?): WEDGE      recovered after ~216s (epoch 0)
  ✗ restart 4 (epoch 0 -> ?): WEDGE      recovered after ~222s (epoch 0)
  wedges: 4 / 4 restarts
WEDGES=4 RESTARTS=4 FREEZE_S=6 SKIP_PARENT_STATS=no

Two earlier red runs (before the recovery fix) also wedged, but the first restart after a fresh epoch 0 came through 2 of 3 times. Forcing the fault makes a wedge very likely, not certain.

Green: knob true (the chart default). Same cluster, up again (a helm upgrade that rolls the proxy), same fault:

  envoy --skip-hot-restart-parent-stats: yes
  ✓ restart 1: epoch 1 -> 2 responsive (18:52:16Z)
  ✓ restart 2: epoch 2 -> 3 responsive (18:52:53Z)
  ✓ restart 3: epoch 3 -> 4 responsive (18:53:31Z)
  ✓ restart 4: epoch 4 -> 5 responsive (18:54:08Z)
  ✓ restart 5: epoch 5 -> 6 responsive (18:54:45Z)
  ✓ restart 6: epoch 6 -> 7 responsive (18:55:23Z)
  wedges: 0 / 6 restarts
WEDGES=0 RESTARTS=6 FREEZE_S=6 SKIP_PARENT_STATS=yes

Soak gates (e2e/soak/README.md, "The hot-restart wedge gates (#1050)")

Each gate is graded per roll.

  • (a) Zero liveness watchdog fired and zero drain deadline elapsed, killing envoy epoch for an epoch with a live child, as LogsQL over service.name="aether-proxy". The zero only counts if starting workers returns one line per node per roll over the same window; otherwise it is vacuous.
  • (b) Source-side 503 UC with QUIC_TOO_MANY_RTOS|Network_blackhole_detected toward the rolling node stays at baseline (0 on non-wedged rev248 rolls vs ~550 on the wedged one). QUIC_PUBLIC_RESET at a roll is the separate, milder case.
  • (c) A successor that is silent for 10 s after starting workers is the wedge signature, whether or not the watchdog later fires.
  • The kind red/green recipe above.

Runbook

New docs/runbook.md section, "A roll wedges both epochs after starting workers (#1050)", covering:

  • the symptom and the deadlock
  • the knob and its cost
  • what remains: duplicateParentListenSocket on an LDS add inside the window is the same blocking, timeout-less call, and the parent's main thread can still stall without deadlocking
  • the upstream fix shape: non-blocking forward that drops on EAGAIN, and receive timeouts on the child. Nothing was posted upstream.

Not in this PR

  • A supervisor metric/log for "child silent >10 s after starting workers". The supervisor does not read Envoy's log stream, so this is not a few-line change. Gate (c) grades it from logs for now; follow-up.
  • The restartCount 0 seen on talos after the watchdog fired. On kind the watchdog exit did restart the container.

Closes #1050. The observed deadlock is removed, and the red/green run above shows it. The remaining duplicateParentListenSocket trigger and the upstream Envoy fix are separate findings and belong in their own issue, not in this one.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 4 commits September 28, 2026 15:09
…1050)

The hot-restart child's periodic getParentStats is a blocking, timeout-less
recvmsg on the parent's main thread, while the parent's main thread forwards
unowned QUIC/UDP datagrams to the child with a blocking, timeout-less sendmsg.
When the child's datagram queue fills during a stats request both main threads
wait on each other forever. proxy.hotRestart.skipParentStats (default true)
removes the only periodic child->parent blocking call.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…adlock

e2e/hotrestart-wedge.sh drives h3 load through SIGHUP hot restarts on the
eastwest-quic bring-up and flags a WEDGE when the new epoch's admin stays
dark >= 5 s, then captures per-thread syscall/wchan/kernel stacks and
(WEDGE_GDB_IMAGE) symbolized main-thread backtraces of every envoy.

Unforced (17 h3 listeners, ~1900 inbound rps, 30 restarts): 0 wedges.
WEDGE_FREEZE_S=6 (SIGSTOP the child inside the parent's forwarding
window) wedges 3/3 with the production signature: parent main thread in
runPostCallbacks -> RpcStream::sendHotRestartMessage (forwarded UDP,
blocking sendmsg, sock_alloc_send_pskb), child main thread in
flushStatsInternal -> HotRestartingChild::getParentStats (blocking
recvmsg); both ignore SIGTERM; the 30 s supervisor watchdog kills both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…unbook

The wedge harness applies proxy.hotRestart.skipParentStats at `up`
(WEDGE_SKIP_PARENT_STATS, via HR_SKIP_PARENT_STATS in the eastwest-quic
hot-restart bring-up) and reports what the live Envoy was started with, so
the forced-fault run is a red-then-green check. The soak README grades the
per-roll wedge signature; the runbook explains the deadlock, the flag and
what it does not cover.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…aits out the crash-loop backoff

The node-side `sh -c` that matched `*envoy*--restart-epoch*` carried the
pattern in its own argv and matched itself, so the flag report said "yes"
on a cluster without the flag. After a wedge the watchdog's container
restart backs off longer each time; a fixed 60 s sleep found no supervisor
and a failing admin curl aborted the run under pipefail. Record the
2026-09-28 red (4/4) and green (0/6) results.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit a41b3dd into main Sep 28, 2026
24 checks passed
@bpalermo
bpalermo deleted the fix/1050-skip-hot-restart-parent-stats branch September 28, 2026 19:06
bpalermo added a commit that referenced this pull request Sep 28, 2026
…od's app containers until its SVID exists — the egress twin of the inbound readiness gate (#1053) (#1055)

* feat(identity): injected identity-ready init container holds a mesh pod's app containers until its SVID exists — the egress twin of the inbound readiness gate (#1053)

A pod that sent within ~8 s of its CNI ADD had no SVID yet: the source proxy
had no client certificate for it and connects sat until connect_timeout
(503 UF on h2). The CNI ADD is deliberately not blocked (SPIRE must not become
a hard dependency of sandbox creation); the app container is gated instead.

- agent/cmd/identity-ready: waits on the pod's own SPIRE Workload API
  (csi.spiffe.io, mounted into the init container only) until an X.509 SVID is
  issued, then exits 0. Fail closed by default, periodic WARN naming the socket
  and last error, optional --timeout. Links gRPC + go-spiffe's generated
  Workload API client only; deps_test holds an explicit module allow-list.
  Ships as an extra layer in the agent image.
- controller/internal/podmutate: injects aether-identity-ready FIRST (ahead of
  the pod's own init containers) plus its CSI volume into every mesh pod;
  skips aether.io/identity-gate=false, hostNetwork and mesh-ignored
  namespaces; idempotent; Pod Security "restricted"-compliant.
- chart: controller.webhook.identityGate.{enabled,image,pullPolicy,timeout,
  resources}, default ON, never rendered with spire.enabled=false; chart 1.0.4.
- e2e/eastwest-quic.sh E6: fresh ServiceAccount, request at container start.
  kind: gate off -> first request stalls 3.4-5.4 s for the cert; gate on ->
  gate holds 3.6-4.1 s, first request 200 in 12-14 ms as the new SA.
- docs: workload requirements, configuration, runbook, proposal 036 follow-up.

Closes #1053

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* test(identity): neutral image registry in gate fixtures (check-registry-config)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* chore(chart): aether 1.0.5 — main took 1.0.4 in #1056

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant