Repository navigation
fix(agent): bound the DNS retransmit budget and stop hiding resolution stalls as timeouts (#726) - #728
Merged
Conversation
…n stalls as timeouts (#726) The roll-correlated 16-31 request bursts on `<svc>.<ns>.aether.internal:18081` are not a data-plane defect. The failing requests never reach Envoy: across the 2026-09-06 12:29:30-12:32:00Z burst there is not one non-200 source access log anywhere in the mesh (control-tested both ways), while the prober's per-path counter steps +16. The mesh-domain and cluster.local spellings resolve to the same ClusterIP, hit the same capture listener, and are served by the same `aether-test/echo` EDS resource, so nothing downstream of resolution can produce a one-path burst. What happens instead: mesh-DNS rolls with maxSurge:1/maxUnavailable:0 and no preStop, so the predecessor's SO_REUSEPORT UDP socket is closed the moment the successor's first readiness probe passes. A datagram steered at the departing socket in that window is silently discarded. The client then waits the stock resolv.conf `timeout:5`, and because Go's resolver singleflights by name, that one lost packet stalls every concurrent lookup of that name for the full 5s. Measured gap: 12:30:40.841Z -> 12:30:45.947Z = 5.106s, with the queued probes released in a visible pile-up on resume. Probes issued in the first ~3.1s blow their own 2s budget (3.1 x 4.99 = 16); the rest complete late. Two changes: - podmutate injects `options timeout:1 attempts:3` alongside ndots. The resolver a managed pod talks to is node-local, so 1s is generous, and 3 attempts leave a 3s worst case against the 10s the defaults allow. This turns a lost datagram from a 5s per-name outage into a ~1s hiccup, under the prober's 2s budget and under essentially any client's. An option the workload already declares is never overridden. Derived constants, not flags, for the same reason ndots is. - The prober classifies resolution before its own deadline. The probe budget (2s) is shorter than the resolver retransmit (5s), so ctx.Err() was ALWAYS DeadlineExceeded by the time the error surfaced and `dns_timeout` was structurally unreachable for exactly the failure it names. Three separate investigations read "dns_* is zero" as "DNS is healthy" when it only ever meant "DNS never failed FAST". The function's own comment already prescribed this ordering; the code contradicted it. The aggregate refutes the mesh-domain framing outright: over 24h the largest single burst in the fleet is 81 on the cluster.local path (w01), three of five probers have their worst burst there, and every prober has more cluster.local timeouts than mesh-domain ones. Both names lose the same coin flip; the three samples in the issue caught the mesh side three times. Not addressed here, and worth its own issue: the datagram loss itself. A post-SIGTERM lame-duck window in the mesh-DNS server would narrow it, but the drop is a kernel reuseport-group race at socket close and cannot be fully closed from userspace without eBPF socket steering. Bounding the client's retransmit is what removes the user-visible outage. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Sep 6, 2026
bpalermo
added a commit
that referenced
this pull request
Sep 6, 2026
…onds buckets (#732) (#733) aether_probe_request_duration_seconds records time.Since(start).Seconds() but took the OTel SDK's default explicit boundaries (0, 5, 10, 25 ... 10000), which are tuned for MILLISECONDS. With seconds-valued observations the first bucket is "<= 5 s", so a healthy 2 ms probe and a timed-out 2 s probe are the same bucket: control-tested on talos, all 18,394 pre-fix ~2 s timeout observations on one prober sit in le=5, identical to +Inf, and every derived quantile reads flat. Set explicit seconds boundaries on the instrument (metric.WithExplicitBucketBoundaries, honoured by the pinned otel metric v1.44 -- no View needed), chosen so healthy sub-10 ms probes, the 1 s resolver retransmit (#728), the 2 s probe budget and the 5 s legacy retransmit each land in their own bucket. Name and unit are unchanged. Swept every histogram in the repo for the same mistake and fixed the three others that recorded seconds into the millisecond defaults: aether.agent.snapshot.duration, aether.agent.liveness.promotion_delay_seconds, aether.registrar.sync.duration and aether.replicator.sync.duration. mesh-DNS, the supervisor and the CNI plugin already carried explicit boundaries. The prober test asserts the boundaries on the EXPORTED data point via an sdkmetric ManualReader, so it covers the option actually reaching the SDK, and pins that a 2.0 s observation lands in le=2 and not in le=1.5. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Sep 6, 2026
…roven serving (#729) (#734) On an `aether-mesh-dns` roll (maxSurge:1/maxUnavailable:0, SO_REUSEPORT, readiness initialDelaySeconds:1, no preStop, no drain) the DaemonSet controller deletes the predecessor the instant the successor passes its first readiness probe, and `Server.Start` closed the UDP+TCP sockets on the resulting SIGTERM. Every datagram the kernel had already steered into the departing socket's queue was discarded. #726 Phase 1 traced a 5.106 s hole in the mesh-domain access log to exactly one such lost query: Go's resolver singleflights by name, so one drop stalls every concurrent lookup of that name for a full retransmit timeout. #728 shrank that to ~1 s from the client side; the datagram loss was untouched. Lame duck. On SIGTERM the resolver now removes its ready marker (the pod reports NotReady, which is honest — it IS leaving) and KEEPS SERVING until either a successor is observed answering on the same address or `--lame-duck-max` (default 10s) elapses; only then does it close and exit 0. Successor detection is evidence, not a timer. The resolver answers a reserved identity name, `_instance._aether.<mesh-domain>` TXT, with 64 random bits minted at process start — random, because predecessor and successor are each pid 1 in their own container, so a pid stamp could never tell them apart. The lame duck queries that name OVER THE WIRE at its own listen address every 200 ms. Both processes hold a socket in the reuseport group, so the kernel hashes each probe (fresh source port, fresh hash) at one of them; a reply carrying someone else's stamp proves both halves of what must be true before closing — the successor is IN the group and it ANSWERS. Our own stamp, or no reply, is "not yet". A second SIGTERM cuts the window short (reason=signal); the handler is registered only after the shutdown begins, so the first signal can never be mistaken for it. Residual, stated in the code and unfixable from userspace: close() on a reuseport socket can still discard a datagram queued between the last recvfrom and the close. eBPF sk_reuseport steering would be the complete fix. This narrows the exposure from every roll to that instant. Metrics: aether.mesh_dns.lame_duck.exits{reason=successor|deadline|signal} and aether.mesh_dns.lame_duck.duration (seconds, EXPLICIT seconds buckets — the mistake #732/#733 just swept out of the repo). The histogram builder now requires boundaries rather than defaulting, so the next instrument cannot repeat it. INFO lines: "lame duck started", "successor observed" (both stamps), "lame duck deadline reached", "listener closed". Chart 0.92.7 -> 0.92.8: `agent.meshDnsDaemon.lameDuckMax` (default "10s") and a terminationGracePeriodSeconds DERIVED from it (+5s) so the kubelet can never SIGKILL mid-window; no preStop, since the process handles SIGTERM itself. maxSurge:1/maxUnavailable:0 unchanged. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
This was referenced Sep 6, 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 #726 (mechanism confirmed in #726 (comment)).
The hypothesis in the issue is refuted
#726 proposed that the mesh-domain path is served by an
:authority-named on-demand cluster whose endpoints miss the DRAINING-aware health the service cluster gets. It isn't, on either the data or the code:200source-reporter access log anywhere in the mesh — noUT, noUF, noURX, noDC, no 503. Control-tested both ways so this is not a false zero:response_flags:"UT"returns the k6 504s at 05:54:56Z andNOT response_code:"200"returns aDCon w04 at 12:44:47Z.downstream_local_addressis10.107.111.199:18081(echo's ClusterIP),upstream_clusterisaether-test/echo, andupstream_hostrotates over all three replicas. mesh-DNS returns the mesh Service's ClusterIP, never pod IPs, so there is no pod pinning.echo.aether-test.aether.internal:18081setsEdsClusterConfig.ServiceNameto the bareaether-test/echo(agent/internal/xds/cache/cluster.go:401-421), andbuildHTTPEndpointBucketsappends the same*LbEndpointpointer into every bucket, soHealthStatus_DRAININGreaches every cluster shape by construction. feat(agent): two-phase drain — DRAINING first, pool-close after delay #152 cannot diverge between them — and it never engages here anyway, since rollingaether-proxydeletes noechopods.The confirmed mechanism
The rev204 deploy rolled
aether-mesh-dnstoo, which the issue's timeline missed. On main-worker-02:The DaemonSet is
maxSurge:1 / maxUnavailable:0, readiness is an exec probe withinitialDelaySeconds:1, periodSeconds:15, and there is nopreStopand no drain. Successor binds at:39.63, its first readiness probe passes at ≈:40.6, the DS controller deletes the predecessor, andServer.Startcloses the SO_REUSEPORT UDP socket immediately (agent/internal/meshdns/server.go:493-497). While both sockets are in the reuseport group the kernel hashes each datagram to one of them; a datagram steered at the departing socket in the closing window is silently discarded.The client then waits the stock resolv.conf
timeout:5, and Go's resolver singleflights by name, so that one lost packet stalls every concurrent lookup of that name:12:30:40.841Z12:30:45.947Zsvc.cluster.local, same window…aether.internal…svc.cluster.localThe arithmetic closes: probes issued in the first ~3.1 s of the 5.1 s stall blow their own 2 s deadline (
3.1 × 4.99 ≈ 16); the rest were still queued when resolution completed and were released in a visible pile-up — three requests inside 1 ms at12:30:45.947/.948/.948, twelve inside 0.6 s, far above the 5/s tick.The mesh-domain path is not disadvantaged. Largest single burst per prober over 24h:
svc.cluster.localaether.internalThe biggest burst in the fleet is on cluster.local, three of five probers have their worst there, and every prober has more cluster.local timeouts lifetime than mesh-domain ones. Both names lose the same coin flip; the three samples in the issue caught the mesh side three times.
The change
1. Bound the retransmit cost —
controller/internal/podmutateThe pod-mutating webhook now injects
options timeout:1 attempts:3alongside the existingndots. The resolver a managed pod talks to is node-local (the CNI DNATs:53to the node's mesh-DNS), so a query that gets no answer is a dropped one, not a slow one — 1 s is generous, and 3 attempts leave a 3 s worst case against the 10 s the defaults allow. A lost datagram costs ~1 s instead of 5 s: under the prober's 2 s budget and under essentially any client's.ndotsis derived from--mesh-domain(the retired--pod-ndots): the value follows from the topology, not from an operator preference. No chart change, so noChart.yamlbump.2. Make the class observable —
prober/internal/proberclassifyErrtestedctx.Err()before the*net.DNSErrorbranch. The probe budget (2 s) is shorter than the resolver retransmit (5 s), soctx.Err()was alwaysDeadlineExceededby the time the error surfaced, anddns_timeoutwas structurally unreachable for exactly the failure it exists to name. Three separate investigations read "dns_*is zero" as "DNS is healthy" when it only ever meant "DNS never failed fast". The function's own comment already prescribed DNS-first; the code contradicted it.The reorder is safe because
*net.DNSErroris produced only by resolution: Go returns one (withIsTimeoutset) when the deadline cancels a lookup in flight, and a plainOpErrorwith noDNSErrorinside when the deadline lands on a post-resolution connect. Connect stalls still classify astimeout.Every pre-existing
classifyErrsubtest passedcontext.Background(), which is precisely why this survived. The new subtests pin the already-expired-context case in both directions.MeshDNSResolutionFailingalready matcheddns_timeout|timeout, so alerting behaviour is unchanged; its comment (which documented the misconception) is corrected.Not in this PR
Eliminating the datagram loss itself. A post-SIGTERM lame-duck window in
Server.Start(drop the ready marker first, keep serving briefly, then close) would narrow it, but the drop is a kernel reuseport-group race at socket close and cannot be fully closed from userspace without eBPF socket steering. Bounding the client's retransmit is what removes the user-visible outage; narrowing the window is second-order. Worth its own issue.Generated xDS
Unchanged. Nothing in this PR touches the xDS cache or proxy packages, and
//test/envoy_validateis unaffected.Validation on talos-main
The webhook mutates on CREATE only, so existing pods keep the old resolv.conf until recreated. Sequence:
kubectl -n aether-test rollout restart ds/prober) so they pick up the newdnsConfig. Confirm on one:kubectl -n aether-test get pod <prober> -o jsonpath='{.spec.dnsConfig}'→ must showndots:2,timeout:1,attempts:3.aether-mesh-dnsDaemonSet rolls under steady prober load (this is the trigger — not the proxy roll). Ten rolls is the floor: the historical hit rate is ~1 in 3, so 10 gives ~97% power to see at least one pre-fix-sized burst if the fix did nothing.rate()/increase()— the counters are OTLP-pushed andrate()lies across scrape gaps.dnsConfigfirst.result="dns_timeout"rather thanresult="timeout". A non-zerodns_timeoutafter this deploy is the fix working as an observability change, not a regression — gradedns_timeout + timeouttogether against the oldtimeoutbaseline.aether_probe_requests_total{result="dns_nxdomain"}stays at its baseline (a too-aggressive retransmit would surface as spurious NXDOMAIN from truncated search-list walks).🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr