Repository navigation
fix(supervisor): anchor the successor's ready gate to its first LIVE and keep holding readiness while the admin is busy, so the old pod is never deleted mid-handoff (#991) - #1026
Merged
Conversation
…and keep holding readiness while the admin is busy (#991) Under soak load the successor Envoy's fork -> "starting workers" grew from 2.2-3.5s (rev239) to 3.2-6.0s (rev242), and the old aether-proxy pod was deleted mid-handoff on 22 of 30 rolls: - Group A (13/30): the ready gate was fork + ParentShutdownTime + 3s, but Envoy arms parent shutdown in startWorkers(). The gate now is max(fork + PST + 3s, firstLiveObserved + PST + 2s), with PST the value passed to envoy as --parent-shutdown-time-s. Logged as "successor ready gate anchored" with its anchor (fork|live). - Group B (9/30): the parent's readiness hold dropped on one unreachable /server_info tick while the successor's main thread was busy loading its first listener batch. The hold now survives an unreachable admin for the existing admin watchdog bound (adminUnresponsiveDeadline, 30s default), logged once per streak as "holding readiness through unreachable admin". The supervisor gets an injectable clock so the coordination state machine is tested on a fake clock; both new gates were seen red with the two rules reverted. Runbook documents both rules, their bounds, the log lines and the fleet gate (shutdown_branch{branch="handoff"} ~0 per roll). 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.
Problem (#991)
On the rev242 soak (0.95.3,
cb79180) the oldaether-proxypod was deleted mid-handoff on 22 of 30 node-rolls: its supervisor loggedtermination requested mid-handoffand recordedshutdown_branch{branch="handoff"}. The data plane stayed clean because every case took thehandoffarm. But the #132/#795 invariant (the old pod stays until the successor has taken over) was broken. A successor that wedges before going LIVE would have left the node on the 155 sdrain_fallbackrather than on an old pod that is still Ready.Nothing in the supervisor or the chart changed between rev239 and rev242. What changed is the successor Envoy's fork →
starting workerstime under load: 2.2–3.5 s on rev239, 3.2–6.0 s on rev242 (one outlier at 31 s). That broke two assumptions:successorReadyGate()made the successor Ready at fork + 15 s + 3 s = fork + 18.0 s. Envoy arms its parent-shutdown timer instartWorkers(), not at the fork:shutting down parent after drain − starting workersmeasured 14.93–15.00 s on every roll. So the predecessor died at 18.2–21.0 s, after the gate, and the DaemonSet deleted the old pod about 1 s after the new one went Ready.onNotLiveEpochheld the old pod's readiness only whileready && reachable && anyChildTracked()(fix(supervisor): hold readiness while serving as hot-restart parent #132). During the handoff the admin port belongs to the successor, whose main thread is busy loading its first listener batch (13inbound_*_h3listeners on w05). One/server_infoprobe over its 1 s timeout cleared the marker. Three failed exec probes at 2 s later the pod went NotReady, and with a surge pod already present the DaemonSet deleted it at once.pod not readycame 5.0–6.3 s before each early SIGTERM.Fix (both in
agent/internal/proxy/hotrestart)liveAnchoredReadyGate, called fromonLiveEpochon the gated epoch's first LIVE):readyGate = max(fork + ParentShutdownTime + 3s, firstLiveObserved + ParentShutdownTime + 2s)ParentShutdownTimeiscfg.ParentShutdownTime, the same valuebuildEnvoyCmdpasses as--parent-shutdown-time-s, not a literal.initStartEpocharmed. In-pod hot restarts and fresh epoch-0 starts are unaffected.LIVE + PST + 0.9 s(measured), and the observed LIVE is never earlier than the real one.successor ready gate anchored anchor=fork|live sinceFork=… readyGateIn=… readyGateAfterFork=…. The fork gate is now also logged onlive predecessor confirmed(readyGateIn,readyGateAnchor=fork).hold := ready && anyChildTracked() && (reachable || now − unreachableSince < adminUnresponsiveDeadline())adminUnresponsiveDeadline()(--admin-unresponsive-deadline, 30 s default). No new constant.checkWedgeWatchdogsrestarts the container.holding readiness through unreachable admin: successor likely initializing … holdBound=30s.To make the state machine testable, the supervisor gets an injectable clock (
Supervisor.now,time.Nowoutside tests). It is used by the gate, the hold and the two wedge watchdogs.Gates, each seen RED
New file
agent/internal/proxy/hotrestart/handoffgate_test.godrivesonLiveEpoch/onNotLiveEpoch/checkWedgeWatchdogson a fake clock.TestSuccessorReadyGateAnchorsOnFirstLive: LIVE at fork + 5 s. Not Ready at fork + 18 s, nor 1 ms before LIVE + 15 s + 2 s; Ready at that pointTestReadinessHeldThroughBusySuccessorAdmin: admin unreachable for 1, 2, 3 s and then 29 s with a child tracked. The marker is heldTestReadinessHoldThroughUnreachableAdminIsBounded: unreachable past 30 s. The marker is cleared, the admin watchdog fires on the same tick, and with no child tracked there is never a holdTestSuccessorReadyGateKeepsForkFloorOnFastLive(control: LIVE at +0.5 s keeps fork + 18 s)TestLiveAnchorIgnoresUngatedEpochs(in-pod epoch and epoch-0 are never gated)How red was shown: the clock plumbing was kept, and only the two decision rules were reverted to today's code (
adminAnswering := reachable, andliveAnchoredReadyGatereturning early). With that,--- FAIL: TestSuccessorReadyGateAnchorsOnFirstLiveand--- FAIL: TestReadinessHeldThroughBusySuccessorAdmin, and every other test passed. With the fix restored, all pass.The existing tests are unchanged and green: #132 hold, S16
TestInitStartEpochPublishesEpochAndGateTogether(the fork gate is still armed atomically with the epoch), S17, #795 / successor_wait, and the #729 lame duck. The only edit to them is the newunreachableSinceargument in the twoonNotLiveEpochcalls inepoch_test.go.No integration harness runs a real Envoy for the supervisor under
test/ore2e/, so the unit gates plus the next soak are the validation.Verification
bazel test //agent/internal/proxy/... //agent/cmd/proxy-supervisor/...: 3/3 pass. That includes//agent/cmd/proxy-supervisor:deps_test; the supervisor binary gains no dependencies (stdlib only).--config=race //agent/internal/proxy/hotrestart:all: pass.build --config=lint --@aspect_rules_lint//lint:fail_on_violation //agent/...: clean.run //:format: no diff.Expected cost
Successor Ready moves from fork + 18.0 s to roughly fork + 19.5–23 s under load, which is 1.5–5 s per node-roll. An unloaded successor that is LIVE within about 1 s keeps the fork gate (
anchor=fork), so the cost there is 0. No chart change is needed.Fleet gate for the next soak
sum by (k8s_node_name) (increase(aether_supervisor_shutdown_branch_total{branch="handoff"}[<roll window>]))should be ≈ 0 per roll. On a healthy roll the old pod's Envoy is terminated by the successor's parent-shutdown before the successor goes Ready. The old pod then turns NotReady on its own (nothing of its own is left running) and logs notermination requested. A non-zero count is again a finding. It was 1 per node on 22 of 30 rolls on rev242.termination requested mid-handofflines should be 0. A line 5–6 s after the same pod'spod not readymeans rule 2 failed. A line at about fork + 19 s, after the successor'spod ready, means rule 1 failed.successor ready gate anchored anchor=liveon loaded rolls, withreadyGateAfterFork≈ fork→LIVE + 17 s.Docs
The new
docs/runbook.mdsection "How a proxy roll hands the node over" covers both rules, their bounds, the log lines to grep and the fleet gate. The branch-PromQL comment in the SIGTERM section now says thathandoffduring a rolling upgrade is a finding.e2e/soak/README.mddoes not state the +18 s number, and no separate supervisor metrics doc exists, so neither needed changes.Closes #991
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr