Skip to content

fix(proxy): a hot-restart successor waits for CDS+LDS instead of going LIVE empty and draining the parent (#1085) - #1091

Merged
bpalermo merged 3 commits into
mainfrom
fix/1085-successor-waits-for-lds
Sep 30, 2026
Merged

bpalermo merged 3 commits into
mainfrom
fix/1085-successor-waits-for-lds

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Closes #1085

What broke

On w05 during the 2026-09-30 re-soak, a hot-restart successor was forked while the node agent (the xDS server, over /run/aether/xds.sock) was down. The successor's initial CDS fetch timed out at +15 s and its initial LDS fetch at +30 s. It then logged all dependencies initialized. starting workers with zero listeners, and the parent logged closing and draining listeners 2 ms later. 127.0.0.1:18081 refused connections until ADS reconnect backoff finally delivered the listeners. The parent was healthy the whole time.

Envoy facts (pinned 726d7acb73934085cbbccc83ea47fdd78b583d7e)

The carried patches do not change any of these sites. aether1050 only adds allow_failure to the drain RPC.

Question Answer Source
When does the child tell the parent to drain? Only at init complete. The startWorkers completion calls restarter_.drainParentListeners() and then drain_manager_->startParentShutdownSequence(). startWorkers is reached only through RunHelper's post-init callback (cm.setInitializedCb → init_manager.initialize). source/server/server.cc:962-979, :1063-1079, :1086-1091
When does --parent-shutdown-time-s start? At the same moment, init complete. It does not start at the fork. source/server/drain_manager_impl.cc:217-232
When does the parent's --drain-time-s start? When the parent processes the DrainListeners RPC, which logs closing and draining listeners. hot_restarting_child.cc:168-180 → hot_restarting_parent.cc:124-125, 261-265 → server.cc:158-159
Does a timed-out initial fetch count as initialized? Yes. FetchTimedout → callbacks_.onConfigUpdateFailed → CDS runInitializeCallbackIfAny() / LDS init_target_.ready(). The code comment says "allow server startup to continue". extensions/config_subscription/grpc/grpc_subscription_impl.cc:127-131, common/upstream/cds_api_impl.cc:120-126, common/listener_manager/lds_api.cc:152-158
What does initial_fetch_timeout: 0 do? No timer is created (if (init_fetch_timeout_.count() > 0)), so init blocks until the resource arrives. The default is 15 s. The proto says "0 means no timeout". grpc_subscription_impl.cc:33-38, common/config/utility.cc:208, api/envoy/config/core/v3/config_source.proto:260-267
Can a broken stream complete init instead? No. ConnectionFailure only bumps update_failure. Delta-mux establishment failures are reported as ConnectionFailure, and CDS and LDS both ASSERT they never see it. grpc_subscription_impl.cc:121-124, delta_subscription_state.cc:286-289

Setting initial_fetch_timeout: 0s on the bootstrap cds_config and lds_config is therefore enough on the Envoy side. The successor stays PRE_INITIALIZING/INITIALIZING until CDS and then LDS arrive, and the parent drain and parent-shutdown timers are not armed until it really has listeners.

Changes

  1. charts/aether/templates/agent-proxy-configmap.yaml: adds initial_fetch_timeout: 0s on cds_config and lds_config only. EDS, RDS and SDS keep their timeouts on purpose. Those are per-resource config sources the agent generates, and a fetch that never ends there would pin a cluster or listener in warming at runtime (proxy roll: a new Envoy epoch served 404 NR (route_not_found) on the egress listener for 2.8 s before it was Ready — first non-zero liveness since 08-02 #817, QUIC: a twin cluster added after its base is subscribed never receives EDS (delta WatchMap dedup on the shared EDS name) — 15 s of 503/NC for every new ServiceAccount on a node #1008). Their timeouts also only matter after CDS/LDS have arrived, which means the agent is already answering. g-c-p answers a wildcard subscription's first request even when it is empty (pkg/cache/v3/simple.go:605), so init cannot hang while the agent is up.
  2. Supervisor handoff watchdog is now init-aware (agent/internal/proxy/hotrestart).
    • The problem: the 2 m watchdog counted from the fork alone. With the fix above, an agent outage longer than 2 m would have made it SIGTERM an in-pod parent that was serving the node, turning a wait into an outage.
    • The change: it now counts from whichever is later, the fork or the successor's last admin answer at its own epoch. adminServerInfo already attributes every answer to the epoch that gave it.
      • A successor waiting on xDS answers on every tick, so it is never declared wedged.
      • The 2026-06-10 wedge still fires HandoffDeadline after the last answer. That wedge is a main thread blocked in a hot-restart RPC, with the admin never accepting.
    • A successor held past the deadline is logged once per epoch: hot-restart successor still initializing past the handoff deadline. The --handoff-deadline help text is updated to match.
  3. Chart 1.0.16 → 1.0.17.

First start (epoch 0)

If the agent comes up late, epoch 0 now waits in init instead of going LIVE with zero listeners at +30 s. The pod was not usefully Ready before this change either, and epoch 0 is outside the handoff watchdog. This was observed on kind after a workstation reboot with the agent still removed. Epoch 0 sat in PRE_INITIALIZING for more than 5 minutes with no fetch timeouts, then went LIVE about 8 s after the agent DaemonSet was restored.

Evidence

Unit tests: red, then green

  • //charts/aether:aether_proxy_bootstrap_cds_lds_wait_test pins both fields. Against main's configmap it fails with does not contain the pattern: lds_config:\n\s+ads: \{\}\n\s+initial_fetch_timeout: 0s\n.
  • agent/internal/proxy/hotrestart/handoffinit_test.go has four tests: holds a successor that keeps answering for 10 min, still fires once it goes silent, parent answers do not count, and a real Run loop with a 1 s deadline. All four fail against main's coordination.go. For example: Run returned while the successor was answering INITIALIZING at its epoch: hot-restart handoff watchdog: epoch 1 not LIVE within 1s of launch.

Real Envoy hot restart (the deployed proxy binary, @pinned_envoy_linux_amd64)

Setup: epoch 0 serves a static 127.0.0.1:18081. Epoch 1 is forked with the chart's ADS-only dynamic_resources, and the xDS socket is absent.

  • main bootstrap (red):
    • 15 s: initial fetch timed out …Cluster.
    • 30 s: initial fetch timed out …Listener and, in the same millisecond, starting workers. The parent logs closing and draining listeners 2 ms later.
    • 18081 is refused (curl rc=7) from +30.4 s onward.
  • this branch (green): epoch 1 stays PRE_INITIALIZING for 90 s and 86/86 requests are served by epoch 0. In a second run the xDS server came back at +60 s. Epoch 1 got its listener, went LIVE at about +65 s, and took over hitlessly: 95/95 requests served (62 by epoch 0, 33 by epoch 1).

kind (e2e/eastwest-quic.sh up + a scratch leg)

The leg removes the agent pod (DaemonSet nodeSelector), SIGHUPs the supervisor 3 s later to trigger an in-pod hot restart (the same Envoy protocol as a cross-pod roll), and probes 127.0.0.1:18081 from client-a's pod netns every 0.5 s.

  • red (main's bootstrap, agent away 60 s): 51 of 165 probes refused. This is the issue's exact log signature: CDS timeout, LIVE at +30 s with no listeners, closing and draining listeners 6 ms after starting workers. The first refusal is at +35 s and the last at +75 s, which is 13 s after the agent was restored.
  • green (this branch, agent away 150 s, past the 2 m handoff deadline): 283/283 served, 0 refused. The successor stayed PRE_INITIALIZING. At +2 m the supervisor logged its one-time still initializing past the handoff deadline warning and killed nothing. The successor went LIVE and drained the parent only after the agent was back.

Suites

  • bazel test passes on the touched packages: hotrestart, supervisorcmd, charts/aether:all, proxy-supervisor, envoy_validate, agent/internal/cmd (44/44).
  • bazel test --config=race passes on hotrestart and supervisorcmd.
  • bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //... is clean.
  • make gazelle and make format were run.

Trade-off and open risks

  • A handoff now waits as long as the agent is down. That is the intended behaviour: the parent keeps serving with its last config and keeps its ADS stream. The costs:
    • A cross-pod successor pod stays NotReady, so a DaemonSet roll stalls on that node until the agent is back. That is visible as a stalled roll plus the new WARN line.
    • A successor that answers its admin but is stuck in init for a non-xDS reason is no longer killed by the handoff watchdog.
  • The successor still waits out ADS reconnect backoff after the agent returns. On kind it went LIVE 28 s after the agent was restored. The parent serves throughout, so this only lengthens the handoff. Bounding the backoff is a separate follow-up (option 2 in the issue).
  • Narrow residual window: if the agent dies after LDS arrives but before RDS/SDS do, a listener still warms out on the 15 s RDS timeout (proxy roll: a new Envoy epoch served 404 NR (route_not_found) on the egress listener for 2.8 s before it was Ready — first non-zero liveness since 08-02 #817). That is unchanged by this PR.
  • The edge Envoy bootstrap (edge-configmap.yaml) is unchanged. It is not hot-restarted, and its readiness already rides an LDS-delivered listener.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 3 commits September 30, 2026 18:45
…g LIVE empty and draining the parent (#1085)

A successor Envoy forked while the node agent (the xDS server) was down
timed out its initial CDS fetch at +15 s and its initial LDS fetch at +30 s,
logged "all dependencies initialized. starting workers" with ZERO listeners,
and the parent logged "closing and draining listeners" 2 ms later:
127.0.0.1:18081 refused connections until ADS reconnect backoff delivered the
listeners. The parent was healthy the whole time.

Envoy facts (pinned 726d7acb73934085cbbccc83ea47fdd78b583d7e; the carried
patches do not touch these sites -- aether1050 only adds allow_failure to the
drain RPC):

- The parent drain and the --parent-shutdown-time-s timer both start at INIT
  COMPLETE, not at the fork: source/server/server.cc:962-979 (startWorkers
  completion calls restarter_.drainParentListeners() then
  drain_manager_->startParentShutdownSequence()), reached only via RunHelper's
  post-init callback (server.cc:1086-1091, cm.setInitializedCb ->
  init_manager.initialize at server.cc:1063-1079). The timer itself is armed
  in drain_manager_impl.cc:217-232. The parent's --drain-time-s starts when it
  processes the DrainListeners RPC (hot_restarting_parent.cc:124-125 ->
  261-265 -> server.cc:158-159 "closing and draining listeners"), which the
  child sends from hot_restarting_child.cc:168-180.
- A timed-out initial fetch completes init as if it had succeeded:
  grpc_subscription_impl.cc:127-131 (FetchTimedout -> callbacks) ->
  cds_api_impl.cc:120-126 and listener_manager/lds_api.cc:152-158 ("allow
  server startup to continue").
- initial_fetch_timeout 0 means no timer: grpc_subscription_impl.cc:33-38
  only creates it for count() > 0; the default is 15 s
  (common/config/utility.cc:208; config_source.proto:260-267 "0 means no
  timeout"). A stream failure never completes init: ConnectionFailure only
  bumps update_failure (grpc_subscription_impl.cc:121-124; the delta mux
  reports establishment failures as ConnectionFailure,
  delta_subscription_state.cc:286-289), and CDS/LDS assert they never see it.

So `initial_fetch_timeout: 0s` on the bootstrap cds_config/lds_config is the
whole Envoy-side fix: the successor stays INITIALIZING until CDS then LDS
arrive, the parent keeps serving, and the drain + parent-shutdown timers
start only once the successor really has listeners. EDS/RDS/SDS keep their
timeouts on purpose: they are agent-generated per-resource sources, where a
fetch that never ends would pin a cluster/listener in warming at runtime
(#817, #1008), and they only matter once the agent is answering. A first
start (epoch 0) with the agent late now waits instead of going LIVE with
zero listeners at +30 s; the pod was not usefully Ready before either, and
epoch 0 is outside the handoff watchdog. The agent's g-c-p snapshot cache
answers a wildcard subscription's first request even when empty
(pkg/cache/v3/simple.go:605), so init cannot hang against a live agent.

Supervisor: the handoff watchdog (2 m) counted from the fork alone, so an
agent outage longer than that would now have SIGTERMed an in-pod parent that
is serving the node. It now runs from the later of the fork and the
successor's last admin answer at ITS OWN epoch: a successor waiting on xDS
answers PRE_INITIALIZING/INITIALIZING on every tick and is never declared
wedged; the 2026-06-10 wedge (main thread blocked in a hot-restart RPC, admin
never accepting) still fires HandoffDeadline after the last answer. A
successor held past the deadline is logged once per epoch.

Tests: //charts/aether:aether_proxy_bootstrap_cds_lds_wait_test pins both
fields (red against main's configmap); handoffinit_test.go covers the
init-aware watchdog on a fake clock and through the real Run loop (all four
red against main's coordination.go).

Closes #1085

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