Repository navigation
fix(supervisor): send the self-drain only to this supervisor's own Envoy, never to another proxy pod's Envoy on the shared admin address (#1127) - #1134
Merged
Conversation
…voy, never to another proxy pod's Envoy on the shared admin address (#1127) Proxy pods are hostNetwork, so 127.0.0.1:9901 is one address for the whole node. The only state-changing admin request the supervisor makes is the drain_fallback POST /drain_listeners?graceful, and it went to whatever answered. On 2026-10-01 the old pod's Envoy had handed its admin to a successor that then crashed (#1126). The new pod's fresh epoch-0 Envoy bound the port, the old supervisor's successor wait expired, and it drained that Envoy. That Envoy then added no listeners for new pods until the next handoff. Every forked Envoy now gets --admin-address-path set to a per-supervisor nonce (<ready-marker dir>/envoy-admin-address.<pod>.<random>). /server_info echoes it as command_line_options.admin_address_path. The drain is sent only when /server_info returns that nonce AND an epoch whose child this supervisor still tracks. The check and the drain go over the same TCP connection, so there is no window in which the port can change hands. A foreign Envoy, an unreachable admin, or an exited own Envoy means nothing is sent. The supervisor logs one WARN naming whose Envoy answered, and the shutdown path continues. New counter: aether.supervisor.admin_mutations{request,owner}. --admin-address-path is now reserved: an --envoy-arg that sets it is refused. Kind leg e2e/supervisor-admin-identity.sh, red on the main supervisor (drainAccepted=true, the replaced pod's listener never added) and green on this branch (foreign WARN, listener present, 20/20 x 200). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Oct 2, 2026
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 #1127
Mechanism, confirmed from code and reproduced on kind
The supervisor makes one state-changing admin request:
POST /drain_listeners?gracefulindrainThenShutdown, thedrain_fallbackbranch. It does not callhealthcheck/failorquitquitquit; it stops Envoy with signals (terminateChildren,stopWedged). Every other admin call is a read (/server_info,/ready).On main the drain is sent blind to
cfg.AdminAddress(127.0.0.1:9901). It runs when the successor wait expires, from both thesuccessor_waitand the mid-handoff arm, or straight away with--shutdown-drain-immediately. Nothing checks that our Envoy still owns the admin, or that our Envoy is still alive.A hot-restart child asks its parent to shut down the parent's admin and then binds the admin itself. If that child crashes (#1126), the old Envoy keeps serving with no admin. The new pod's supervisor then starts a fresh epoch-0 Envoy, which binds 9901. When the old supervisor's wait expires (155 s at chart defaults), its drain reaches the new pod's Envoy. That Envoy then adds no listeners for any pod created afterwards.
The kind leg below reproduced this exactly on the main supervisor.
Fix: a per-supervisor identity, verified on the connection that carries the drain
--admin-address-path <ready-marker dir>/envoy-admin-address.<POD_NAME>.<96-bit random>./server_infoechoes the path ascommand_line_options.admin_address_path. Envoy's only other use of the flag is to write its admin address into that file; a failed write is logged and not fatal. The file lives in the pod-localready-markeremptyDir because the root filesystem is read-only.ownAdminRequestdials one TCP connection, sendsGET /server_info, and sends the drain on the same connection only if the answer carries our nonce and an epoch whose child we still track. Envoy serves a connection from the process that accepted it, so there is no window between the check and the drain. The client is raw HTTP/1.1 (req.Write/http.ReadResponse) so a transport cannot silently redial.Connection: closeafter the check) or no child is tracked, nothing is sent. The supervisor logs one WARN withadminOwner,answeredBy=<pod>.<nonce>,answeredEpochandourEpoch, then continues the shutdown path: it waits out the drain window and SIGTERMs its own Envoy.aether.supervisor.admin_mutations{request=drain_listeners, owner=own|foreign|unreachable|own_envoy_gone}, seeded at zero.supervisorcmdrefuses an--envoy-argthat sets--admin-address-path(Envoy rejects the flag twice) and passesPOD_NAME, which the chart already sets, into the identity for log labels.Why not the alternatives
/server_infodoes not report a PID either.--service-node/--service-zone/--service-cluster). The agent keys configuration off these.--base-id-path. Envoy throws if it cannot write the file.--socket-path. It must match across pods for the cross-pod hot restart.--stats-tag. It changes every stat.initStartEpoch, the handoff and ready-gate probes, and the e2e/operatorcurl 127.0.0.1:9901). Moving it would redesign the handoff.Tests
Unit tests (
hotrestart/adminidentity_test.go):--shutdown-drain-immediatelywith a foreign Envoy. All three were red on main (drainHits1, expected 0).[/server_info, /drain_listeners]on one connection.Connection: closeafter the check (no second dial), and an unreachable admin all send nothing.--envoy-arg.TestHandleShutdownFallsBackToDrainWhenNoSuccessorComesused to assert that the drain is sent to an Envoy answering at a newer epoch. That Envoy is the successor's, so the assertion encoded the bug; it now asserts no drain and still checks the wait and the reap.Commands run:
bazel test //agent/internal/proxy/hotrestart/... //agent/internal/supervisorcmd/... //agent/cmd/proxy-supervisor/...: green, includingdeps_test.scripts/check-proxy-supervisor-deps.shreports OK. No new dependencies; stdlib only.bazel test --config=raceon hotrestart and supervisorcmd: green.bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: green.Kind leg:
e2e/supervisor-admin-identity.sh. It uses the eastwest-quic bring-up on clusteraether-1127withproxy.terminationGracePeriodSeconds=45, so the successor wait is 20 s. Steps:quic-apod and assert that its inbound listener appears and that 20 requests fromclient-areturn 200.listeners drained; stopping envoy drainAccepted=truelistener_addedstuck at 25)20 x 000not sending envoy admin request: ... ANOTHER envoy adminOwner=foreign answeredBy=envoy-admin-address.aether-proxy-vddxs.… answeredEpoch=0 ourEpoch=1, thendrainAccepted=false20/20 x 200The first branch run returned 503 for about 6 s while the replaced pod warmed up (its SVID was not yet served, and the first use builds its QUIC twin). Its listener was already present, and a manual request a few seconds later returned 200. The leg now waits up to
SAI_WARMUP_S(60 s) for the first 200 before asserting the batch. The main-image failure happens before that wait, at the missing listener.Risks
admin_mutations{owner="foreign"}counts these.admin_address_path. During the first roll onto this version, the new supervisor treats such an Envoy as foreign: it never drains it, and it would not have owned it anyway. An old supervisor terminating during that roll still drains blind, once.POD_NAMEis already in the proxy container's env.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr