Repository navigation
perf(supervisor): probe /ready in the verified steady state, /server_info only for epoch identity - #647
Merged
Conversation
… admin probe The Envoy-admin watchdog probed /server_info with http.DefaultClient and a streaming JSON decoder that left the response body short of EOF, so Go never pooled the connection: measured on talos-main, cx_total == rq_total == 1/s/node with destroy_remote at 100%. Give the supervisor its own clients instead, and make the probe read its (bounded) body whole. The two clients are a correctness invariant, not tuning. A draining hot-restart parent keeps answering LIVE at its OLD epoch over already-accepted connections for the whole --parent-shutdown-time-s window, so every epoch-identity decision (proposal 001 lessons 2 and 3: initStartEpoch, handleDebounce, handleShutdown) must dial fresh — a pooled answer there would make the old pod SIGTERM the successor's hot-restart parent, the errno-111 node data-plane gap of 2026-06-11. The authoritative client therefore disables keep-alives outright; the pooled fast client is added here but not yet used by any probe. Behavior is identical: adminProbe becomes adminServerInfo on the authoritative client, with the same reachable-vs-live contract, called from the same two places. json.Unmarshal replaces Decoder.Decode now that the body is read whole (Envoy emits exactly one protojson object; a truncated transient response is still a decode failure, i.e. reachable-but-not-live). Also adds the aether.supervisor.admin_probes counter (endpoint × outcome), the per-endpoint fake Envoy admin the tests need (real /ready contract plus connection counting), and records lesson 6 in proposal 001. Refs #646 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
The liveness watchdog needs a boolean pair — live-at-epoch, reachable — and was paying for a full JSON parse of an unbounded /server_info document every second on every node, plus one Envoy admin request per second forever. Continuous profiling on talos-main put adminProbe at ~29% of the supervisor's CPU, most of it encoding/json. Epoch identity is only needed while an epoch is unverified. Once /server_info has confirmed that the Envoy on this node's admin is ours at our epoch, adminProber rides /ready — plain text, HTTP 200 iff LIVE, computed from the same main-thread Utility::serverState(...) call, so equally sensitive to the wedged-main-thread mode the watchdog exists to detect — on one pinned connection. The identity claim is re-confirmed on a fresh connection at least every adminReverifyInterval (15s, under both ParentShutdownTime and the admin-unresponsive deadline), and immediately whenever the epoch changes, our child stops being tracked, or /ready answers anything but a plain LIVE. Every invalidation drops the pinned connection with it, so no epoch-identity answer can ever come off a connection accepted by a since-superseded process. The 1s cadence is unchanged, so detection latency is unchanged. The fast path is structurally unreachable while the handoff watchdog is armed (only a /server_info confirmation can set it, and that same tick marks the epoch live). A cross-pod takeover while our child is still alive stays invisible to /ready for up to 15s; the readiness outcome is identical on both paths (hold while reachable and our child is tracked) and the heartbeat write is a no-op under the downgrade guard, so only a diagnostic log is delayed. Closes #646 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Aug 30, 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 #646.
Mechanism
The proxy-supervisor's liveness watchdog needs one boolean pair per tick — live at our epoch and reachable — and was buying it with a full JSON parse of an unbounded
/server_infodocument once a second on every node, forever.Epoch identity is only load-bearing while an epoch is unverified.
adminProber(new,agent/internal/proxy/hotrestart/adminprobe.go) makes that explicit:/server_infoon the authoritative client. ALIVEanswer at our epoch records(verifiedEpoch, verifiedAt).epoch == verifiedEpoch && childTracked(epoch) && age < adminReverifyInterval (15s), the tick goes to/readyon the fast (pooled) client: plain textLIVE\n, HTTP 200 iff LIVE, computed from the same main-threadUtility::serverState(...)call as/server_info'sstate— so equally sensitive to the wedged-main-thread mode the watchdog exists to detect. Anything but a plain LIVE (or any transport error) invalidates and the next tick re-verifies authoritatively.readyPollIntervalstays 1s, so detection latency is unchanged.adminLiveAtEpoch(initStartEpoch / handleDebounce / handleShutdown) is untouched in behavior — it always takes the authoritative, unpooled path.15s for
adminReverifyIntervalsits below bothParentShutdownTime(60s — a cross-pod takeover is still diagnosed while our parent lives) anddefaultAdminUnresponsiveDeadline(30s).The two-client correctness invariant (lesson 3 / errno-111)
The epoch-identity probe must always run on a FRESH TCP connection. A draining hot-restart parent keeps answering
LIVEat its OLD epoch over already-accepted connections for the whole--parent-shutdown-time-swindow — Envoy flipslive_inInstanceImpl::shutdown(), not indrainListeners().Proposal 001 lesson 3 is that the old pod detects a mid-handoff takeover via its own admin no longer answering at its epoch (
handleShutdown). A pooled/server_infowould invert that: the old pod would believe it is still the serving Envoy, take the plain shutdown path, and SIGTERM the successor's hot-restart parent — the errno-111 node data-plane gap of 2026-06-11.Hence two clients, and the difference between them is a correctness invariant rather than tuning:
adminAuthoritative:DisableKeepAlives: true. Byte-for-byte today's semantics.adminFast: one idle conn, 30s idle timeout, used only by/readyin the verified state.invalidate()clearsverifiedEpochand callsCloseIdleConnections(), so the pinned connection never survives a re-verification boundary or an ambiguous tick.Two structural consequences worth stating:
/server_infoconfirmation setsverifiedEpoch, and that same tick callsmarkEpochLive, while the watchdog requires!wasLive. Thehandoff.durationhistogram is untouched./readyfor ≤15s. The readiness outcome is identical on both paths (hold whileready && reachable && childTracked, per fix(supervisor): hold readiness while serving as hot-restart parent #132), andwriteStateis a no-op under the downgrade guard. Only a diagnostic log is delayed.Before-numbers (talos-main, measured 2026-08-30 — do not re-measure)
process_cpu,service_name="unknown_service:supervisor", 3h window:adminProbe≈ 29% of supervisor CPU, of which json decode ≈21%;dialConn2.6%;gcBgMarkWorker10.9%. (onLiveEpoch/writeState5.1% — pre-existing, see below.)rq_total5.00/s,cx_total5.00/s,cx_active0,destroy_remote100% → one TCP connection per request. Thejson.Decoderleft the body short of EOF, so Go never pooled the connection. No Envoy-side change is needed./ready: plain text<STATE>\n, HTTP 200 iff LIVE.Acceptance / rollout on talos-main (recorded here for the deploy — NOT done in this PR)
Baseline (before-picture):
rq_total5.00/s,cx_total5.00/s,cx_active0,destroy_remote100%; profile shares as above.Staged:
OnDeletestrategy, one canary pod, 30 min, then roll the rest. Never--reuse-values.Acceptance A — cost dropped
rq_total≈ 5.00/s (cadence unchanged),cx_total≈ 0.33/s,cx_active≈ 5.aether_supervisor_admin_probes:ready≈ 4.67/s vsserver_info≈ 0.33/s (the ~14:1 ratio the metric description calls out).adminProbe< 5%, json frames absent,dialConn≲ 0.3%, gc lower./readycontract check viakubectl debug node:curl 127.0.0.1:9901/ready→200, bodyLIVE\n; note the absence ofConnection: close.Acceptance B — watchdog unchanged
wedges_totalstill absent/0;ready_transitions0; epoch flat; no unexpectedchild_exits; zero restarts.Acceptance C — hitless roll harness (e2e/soak, grade on the external prober only)
rollout restart ds/aether-proxyat 15-min spacing under k6 load (+ optional TRIPLE).dns_*0.handoff_durationp95 must not regress — this is the sentinel for the pinned-connection hazard. Stretch toward the 30/60s buckets ⇒ revert commit B (it is an independent rollback lever).child_exits{successor_terminated}= 1/node/roll,{unexpected}= 0;predecessor_detected= 1/node;hot_restart_epoch+1/node/roll; zero restarts.Risks
DisableKeepAliveson the authoritative client,invalidate()(incl.CloseIdleConnections) on every transition. Sentinel =handoff_durationp95./readysemantics diverging in a future EnvoyTestAdminReadyMatchesServerInfoState+ the debug-pod contract check; add to the Envoy-bump checklist.httptestClose racing a live keep-alivet.Cleanup(s.adminFast.CloseIdleConnections)in the test helper.json.Unmarshalstricter thanDecoder.Decodere trailing contentbytes.NewReader+Decodeis a zero-delta fallback.onLiveEpoch → writeState(mkdir+flock+read+write+rename every second, 5.1%) becomes the top Go frameRejected alternatives
/stats?filter=…— the admin/statsendpoint renders on Envoy's main thread and must never be scraped (already documented inagent-proxy-configmap.yaml).json.Decodertoken walk over/server_info— still lexes the whole document; kept only as a fallback if/readyever had to be abandoned.readyPollIntervalto 2–5s — detection latency is the value the watchdog provides; the cost was the parse, not the cadence.Commits
refactor(supervisor)— dedicated unpooled client for the authoritative probe,adminServerInfo, theadmin_probesmetric, the per-endpoint fake admin, proposal-001 lesson 6. Behavior-identical; the full pre-existing suite passes untouched.perf(supervisor)—adminReady+adminProber+ thewatchLivenesswiring. Independent rollback lever.Tests
//agent/internal/proxy/hotrestart/...— 13 new tests (fast-path engagement, interval re-verification, successor takeover, child gone, new epoch, not-live invalidation, unreachable invalidation,/ready↔/server_infostate equivalence table, connection reuse vs. never-pool, pinned-connection drop, admin-hangs-after-LIVE through the realRun, plus the metric attributes).bazel test //agent/... --test_output=errorsgreen;--config=cilint clean;make formatclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr