Repository navigation
fix(proxy): drain and start fresh instead of hot-restarting across an Envoy worker-count change (#1136) - #1147
Merged
Conversation
… Envoy worker-count change (#1136) A hot restart between different --concurrency values re-steers the parent's QUIC connections by the child's count: the child attaches its connection-ID steering program (SO_ATTACH_REUSEPORT_CBPF, CID % concurrency) to the sockets it inherits, and the program belongs to the whole reuse-port group. On 4 -> 2 about half of the parent's live HTTP/3 connections land on a parent worker that does not own them (Mismatched worker index, stateless reset); on 2 -> 4 the child's new, unpaused sockets for workers 2-3 take about half of them. When initStartEpoch confirms a live predecessor, the supervisor now reads its /server_info (command_line_options.concurrency) and compares it with the count its own Envoy will run (--concurrency in the envoy args, else the online CPU count, Envoy's default). The answer is trusted only when it is LIVE, at the heartbeat's epoch and carries an aether supervisor's admin identity (#1127); anything else hot-restarts as before. On a mismatch it logs one WARN naming both counts, drains the predecessor gracefully on the connection that was checked, waits --drain-time, stops it with /quitquitquit after re-checking its identity on that connection, waits for its admin to go, and starts a fresh lineage at epoch 0. Readiness in the new lineage requires an answer carrying our own identity, so a predecessor still answering at epoch 0 cannot make the pod Ready. New counter aether.supervisor.handoff_mode{mode=hot|fresh_after_drain}, seeded at 0. --hot-restart-on-concurrency-change (chart: proxy.hotRestart.hotRestartOnConcurrencyChange) forces the old hot restart. Kind leg e2e/proxy-concurrency-change.sh (two nodes, 16 h3 curl loops): main 4->2: 14 Mismatched worker index lines, 5-10 x 503 per roll; 2->4: 10 x 503. Branch: 0 Mismatched, 0 failed requests in both directions; the fresh start costs a ~2 s no-listener gap per node (max request latency 2.13 s). Chart 2.2.3 -> 2.2.4. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1136
Problem
#1133 stopped a hot restart across a worker-count change from crashing the successor. It still resets about half of the parent's live QUIC connections. The child attaches its connection-ID steering program (
SO_ATTACH_REUSEPORT_CBPF,CID % concurrency) to the sockets it inherits, and that program belongs to the whole reuse-port group:mod 2, so connections withCID % 4 ∈ {2,3}reach a parent worker that does not own them. You seeMismatched worker index. expected 3, actual 1, then a stateless reset. On talos-main on 2026-10-02 this was 34 lines and 12 resets fleet-wide.Change
Only a cross-pod start can see a different count. An in-pod hot restart forks with the supervisor's own
ExtraArgs, which never change for its lifetime. So the check sits whereinitStartEpochconfirms a live predecessor. That point also covers a bind-collision retry./server_info→command_line_options.concurrency. The predecessor is another supervisor's Envoy, so its answer cannot carry our identity. It is trusted only if it is LIVE, at the heartbeat's epoch, and carries an aether supervisor's--admin-address-pathidentity (supervisor: the old pod's self-drain calls the Envoy admin on 127.0.0.1:9901 without checking it is its own Envoy — it drained the NEW pod's freshly started Envoy, which then served no new listeners #1127). Anything else hot-restarts exactly as before: unreachable, unparsable, no identity (a non-aether or pre-supervisor: the old pod's self-drain calls the Envoy admin on 127.0.0.1:9901 without checking it is its own Envoy — it drained the NEW pod's freshly started Envoy, which then served no new listeners #1127 Envoy), another epoch, or no concurrency reported. The check never blocks a normal roll.--concurrencyfrom the envoy args (Envoy keeps the last one). If the flag is absent (the chart default,proxy.concurrency: 0), use the node's online CPU count from/sys/devices/system/cpu/online. That is what Envoy's defaulthardware_concurrency()returns. If it can't be read, hot-restart.mode=hot.envoy worker count changes across this handoff; NOT hot-restarting …) and countmode=fresh_after_drain.POST /drain_listeners?gracefulon the connection that was just checked, then wait--drain-time.POST /quitquitquiton that same connection. The other pod's Envoy is in another PID namespace, so it cannot be signalled. Its supervisor sees exit 0 and takes its existing path:newest epoch terminated cleanly by successor; awaiting pod deletion.adminServerInfocounts an answer as LIVE only if it carries our identity. Otherwise a predecessor still answering at epoch 0 could make the new pod Ready before its own Envoy is up. In every other case readiness is decided exactly as before.--hot-restart-on-concurrency-change(default off, meaning fresh start), chart valueproxy.hotRestart.hotRestartOnConcurrencyChange: false. With it on, a mismatch is logged at WARN and hot-restarted.aether.supervisor.handoff_mode{mode=hot|fresh_after_drain}, seeded at 0.The predecessor drain does not use
admin_mutations(#1127's "onlyowner=ownis sent" counter). It is a deliberate request to the verified predecessor, and both requests ride a connection whose identity was checked.Tests
hotrestart/concurrencychange_test.go, with a fake admin that reportsconcurrencyand implements/quitquitquit:[/server_info, /drain_listeners]), stop on a re-checked connection ([/server_info, /quitquitquit]),nextEpoch=0, ungated, own-identity readiness--concurrencyreadPredecessorrejects ithandoff_modeseeded at 0 per modeRed runs. With
freshStartInsteadOfHotRestartreturningfalseand the identity rule off (main's behaviour), (b), (c), "default differs" and the readiness test fail. With the trust checks removed (a naive implementation), all three (d) subcases fail. (a) and the inconclusive cases pin behaviour main already has, so they cannot be red against main.Commands run:
bazel test //agent/internal/proxy/hotrestart/... //agent/internal/supervisorcmd/... //agent/cmd/proxy-supervisor/...: green, includingdeps_test(stdlib only).bazel test --config=raceon hotrestart, supervisorcmd anddeps_test: green.bazel test //charts/...: green, including the newaether_proxy_hot_restart_on_concurrency_change_test.bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: green.Kind leg (red → green):
e2e/proxy-concurrency-change.shSetup:
aether-1136, two nodes. Sources on the control plane, destinations on the worker, so every request crosses an east-west QUIC twin between two node proxies.helm upgradechanges onlyproxy.concurrency, so only the proxy DaemonSet rolls.Mismatched worker indexA same-count
rollout restarton the branch image tooklive predecessor confirmed; starting cross-pod hot restarton both nodes, so the default path is unchanged.Drain-window cost, measured. On each node:
--drain-time10 s, plus the stop and 1 s settle);predecessor drainedand was LIVE and Ready 1.0 s later.The node had no listeners for about 2 s. Each of the 16 loops had exactly one request that waited it out on SYN retransmits (16 per node, max 2.13 s), and none failed. The previous pod's supervisor logged
newest epoch terminated cleanly by successor; awaiting pod deletionand thenpod not ready.Docs
charts/aether/values.yaml: theproxy.concurrencycomment and the newproxy.hotRestart.hotRestartOnConcurrencyChange.docs/configuration.md: both rows.2.2.3→2.2.4.Risks
proxy.concurrency. That trades a ~50% QUIC reset at an arbitrary point for a bounded, logged, counted gap. The opt-out restores the old behaviour./drain_listenersand/quitquitquitto another pod's Envoy. Each request goes on a connection that has just verified the predecessor's identity and epoch, so neither can reach a different Envoy that took the shared admin port in the meantime (the supervisor: the old pod's self-drain calls the Envoy admin on 127.0.0.1:9901 without checking it is its own Envoy — it drained the NEW pod's freshly started Envoy, which then served no new listeners #1127 failure shape).--concurrency. The online CPU list matches Envoy'shardware_concurrency()for both libstdc++ and libc++. A node whose online CPU count changes between pods (CPU hotplug) would be read as a count change, and that roll would take the fresh path./quitquitquitis refused or the predecessor never releases its admin, the fresh launch bind-collides and the existing in-process retry re-runs epoch detection. The already-drained predecessor is then hot-restarted from, never drained twice.Do not merge before tonight's soak has started.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr