Skip to content

mesh-dns: add a lame-duck window on SIGTERM so the predecessor's SO_REUSEPORT socket keeps answering until the successor is serving (in-flight datagram loss on every roll, #726 root) #729

Closed

Description

@bpalermo

Summary

#726's Phase-1 analysis (see its comment) found the root of the per-roll prober timeout bursts: on an aether-mesh-dns DaemonSet roll (maxSurge: 1, maxUnavailable: 0, reusePort: true, readiness initialDelaySeconds: 1, no preStop, no drain), the predecessor's SO_REUSEPORT socket is closed the moment the successor passes its first probe. Any datagram the kernel had already queued to the predecessor is discarded. The client (stock resolv.conf, timeout:5) retransmits after 5 s, and Go's resolver singleflights by name, so one lost packet stalls every concurrent lookup of that name for 5 s — a 5.1 s hole in the mesh-domain path's access log on 2026-09-06 12:30:40–12:30:45Z, 16 prober timeouts, zero non-200 responses anywhere in Envoy.

#728 shrinks the blast radius from the client side (options timeout:1 attempts:3 injected by the pod-mutating webhook; the prober now classifies resolution failures as dns_timeout). The datagram loss itself is untouched by #728.

Ask

In agent/cmd/mesh-dns / agent/internal/meshdns/server.go: on SIGTERM, keep serving for a lame-duck window (e.g. until terminationGracePeriodSeconds - 2s, or until a successor is observed answering on the same port — both sockets are in the reuseport group, so a self-query that returns the successor's envoy_server_version-style identity or a generation stamp would do) and only then close the socket; add preStop sleep + a matching terminationGracePeriodSeconds in the chart so the kubelet does not race it. This drains the predecessor's queue instead of discarding it. Note the residual: the instant of close() on a reuseport socket can still drop a datagram queued between the last recvfrom and close — a kernel-level race not fully closable from userspace (eBPF sk_reuseport steering would be the complete fix); the lame-duck window reduces the exposure from "every roll" to "a sub-millisecond race".

Validation: ≥10 mesh-dns rolls under prober load, raw per-series counter deltas per path (not rate()); pass = dns_timeout + timeout bursts ≤ 2 per roll on both paths (the #728 recipe).

Refs: #726 (analysis), #728 (client-side mitigation), #578/#583 (mesh-dns decoupling), #674 (forward pool).

Activity

  1. bpalermo commented on Sep 6, 2026

    @bpalermo
    OwnerAuthor

    Validation of #734 on talos-main: PASS

    10 × kubectl -n aether-system rollout restart ds/aether-mesh-dns under steady prober load, rev207 / chart aether-0.92.8-78a78a4f65a4beb82c310678aa12eab1f62b6fc3 (appVersion asserted post-upgrade), mesh-dns image sha256:9ca1b11b…, prober chart 0.2.0-6b1d5a3c…. Window 15:08:45Z → 15:34:43Z, 2026-09-06. No k6 — prober-only load (5 rq/s per path per prober, 5 probers), the load level at which the pre-fix bursts occurred. 90 s settle after each convergence; raw per-series counter deltas throughout.

    50 predecessor handoffs (10 rolls × 5 nodes). 50/50 exited reason="successor". Zero deadline, zero signal. No access-log gap at any of the 50 close instants.

    Pre-flight

    • mesh-dns 5/5 Ready, --lame-duck-max=10s present in args, terminationGracePeriodSeconds: 15, maxSurge:1 / maxUnavailable:0.
    • aether-system restarts 0, no node taints, aether_mesh_dns_ready / _watch_active = 1 and _records = 14 on all five nodes.
    • All five prober pods carry the CREATE-only webhook's injected options: ndots:2, timeout:1, attempts:3 (checked per pod — this is the thing most likely to invalidate the run).
    • aether_mesh_dns_lame_duck_exits_total had no series at 15:07Z. It first appeared after roll 1, reason="successor" on all five nodes.
    • fix(prober): give the seconds-valued duration histograms explicit seconds buckets (#732) #733's seconds-oriented buckets are live and resolving: the deployed aether_probe_request_duration_seconds_bucket carries le = 0.001 … 0.025 … 0.25 … 1 … 5, and mesh_dns mass sits at le=0.25/le=0.5 rather than collapsed into a single le=5. Baseline p50 176.6 / 192.7 ms and p99 0.699 / 0.702 s (mesh-domain / cluster.local); post-run 177.4 / 194.3 ms and 0.717 / 0.729 s — unchanged.

    Per-roll results

    Roll order is by the predecessor's own lame duck started; the per-node figure is the log-derived listener closed − lame duck started.

    roll window (UTC) mesh-dns roll order + lame-duck duration exit reason prober deltas, both paths, all 5 probers bracket gap at close, mesh / ctrl ±60 s window max gap, mesh / ctrl
    1 15:08:53→15:09:34 w01 1.23 > w02 2.40 > w05 0.21 > w04 0.80 > w03 0.20 successor ×5 all zero 0.413 / 0.415 0.897 / 0.960
    2 15:11:29→15:12:11 w03 0.30 > w04 0.20 > w02 0.20 > w05 0.46 > w01 0.80 successor ×5 all zero 0.303 / 0.298 1.037 / 0.995
    3 15:13:49→15:15:13 w03 0.20 > w02 0.49 > w01 0.41 > w05 0.20 > w04 0.20 successor ×5 all zero 0.305 / 0.311 1.210 / 1.207
    4 15:16:51→15:17:35 w01 0.23 > w05 0.61 > w03 0.29 > w04 0.69 > w02 2.00 successor ×5 all zero 0.224 / 0.290 0.793 / 1.006
    5 15:20:09→15:20:52 w03 0.40 > w01 1.00 > w04 0.70 > w02 1.60 > w05 0.22 successor ×5 all zero 0.301 / 0.299 0.999 / 1.498
    6 15:22:29→15:23:11 w05 0.40 > w02 0.40 > w01 0.41 > w04 0.20 > w03 0.80 successor ×5 all zero 0.312 / 0.301 1.080 / 1.498
    7 15:24:50→15:25:45 w04 0.20 > w05 0.21 > w03 0.60 > w02 0.23 > w01 0.60 successor ×5 all zero 0.394 / 0.302 0.998 / 1.110
    8 15:27:52→15:28:19 w03 0.81 > w02 0.40 > w04 0.63 > w05 0.20 > w01 0.20 successor ×5 all zero 0.493 / 0.305 1.087 / 0.901
    9 15:29:56→15:30:38 w02 0.63 > w04 0.20 > w01 0.80 > w03 0.60 > w05 0.61 successor ×5 all zero 0.308 / 0.404 1.000 / 0.899
    10 15:32:18→15:33:12 w02 0.60 > w04 0.23 > w01 0.20 > w05 0.40 > w03 0.81 successor ×5 1 connection_error (prober-2c48t/w05, mesh-domain) 0.412 / 0.380 0.999 / 1.024

    "all zero" = 0 for every one of timeout, dns_timeout, dns_error, dns_nxdomain, connection_error, http_error, on both paths, on all five probers.

    The three INFO lines, all 50 handoffs

    Queried by pod name from VictoriaLogs (the predecessors are deleted, so logs --previous is not available):

    "lame duck started"   → 50   (10 rolls × 5 nodes, exactly)
    "successor observed"  → 50   (set difference against "started" is empty)
    "listener closed"     → 50   (set difference against "started" is empty)
    "lame duck deadline reached"                        → 0
    "lame duck aborted by a second termination signal"  → 0
    

    Both zeros are control-tested: the same OR query shape with "mesh DNS resolver listening" substituted returns rows, so the syntax finds lines when lines exist.

    The successor= stamp on each successor observed line is the next generation's instance= — e.g. sslmf (instance=d18e9f33a7a26783) observed da3590cab6e51532, which is wkhcm's stamp, and wkhcm in turn observed 642755cdca17b0c2 = xxlkn. The chain closes on every one of the 50 handoffs, so this is real over-the-wire successor evidence, not a timer that happened to expire.

    Log-derived durations agree with aether_mesh_dns_lame_duck_duration_seconds_sum to 3 decimal places on every node, every roll.

    lame-duck duration (n=50) value
    min 0.203 s
    median 0.405 s
    max 2.404 s (w02, roll 1)
    > 1.5 s 3 (all w02: 2.404, 2.004, 1.604)
    ≥ 10 s (deadline in disguise) 0

    The PR predicted 0.3–1.5 s. 47 of 50 land there; the three excursions are all main-worker-02 and all still ~4× inside the 10 s budget, with reason=successor. Worth a note, not a finding: w02's successor takes ~2 s to become steerable in some rolls, which is exactly the case the evidence-based window exists to absorb — a fixed 1 s preStop sleep would have closed the socket early on those three.

    Access-log gap method (#726 Phase 1) — the direct measurement of the residual

    For all 50 closes (not just the 2 earliest-rolled per roll), ±60 s around the predecessor's listener closed, on the prober co-located with that node, on both paths. Every window returned 598–602 records — a complete 5.0/s stream, no truncation. Every record in all 100 windows was 200 / response_flags:"-".

    The decisive figure is the gap that brackets the close instant (last record at or before → first record after):

    bracketing gap, n=50 mesh-domain cluster.local (control)
    min 0.093 s 0.098 s
    median 0.212 s 0.210 s
    p90 0.312 s 0.305 s
    max 0.493 s 0.415 s
    ≥ 1 s 0 0

    The two distributions are indistinguishable, and both are just the 5 rq/s inter-arrival spacing. Compare #726's pre-fix measurement: a 5.106 s hole on the mesh-domain path while the control path ran continuously at 5.06/s. That signature is absent from all 50 handoffs.

    The ±60 s window maxima (mesh 1.210 s, ctrl 1.498 s across ~30,000 intervals each) are ambient jitter, not the handoff — three independent reasons:

    1. They are not at close instants (the worst mesh one, 1.210 s, is at 15:13:17.59, ~54 s before roll 3's nearest close).
    2. The control path's worst gap is larger than the mesh path's.
    3. A no-roll baseline confirms it: over the quiet pre-run window 15:03:30–15:08:00Z (5.00/s on every prober) plus the post-run quiet window, ~12,000 intervals per path with zero mesh-dns rolls produced max 1.104 s (mesh) / 1.092 s (ctrl) and 2 / 3 gaps ≥ 1 s.

    Totals over the 10 rolls

    quantity value
    timeout / dns_timeout / dns_error / dns_nxdomain, both paths 0 / 0 / 0 / 0
    http_error, both paths 0
    connection_error 1 (prober-2c48t, mesh-domain)
    largest single-roll burst, either path 1
    rolls with any burst ≥ 3 0
    rolls with a deadline exit 0
    largest lame-duck duration 2.404 s
    largest bracketing access-log gap, mesh-domain 0.493 s
    liveness non-success 0 / 40,764 probes
    successful mesh_dns probes 81,552 (40,775 mesh-domain + 40,777 cluster.local)
    mesh-dns restarts 0 (restartCount 0 fleet-wide; SIGTERM exits are pod replacements, not restarts)
    aether-system restarts / node taints 0 / none
    mesh-dns ERROR or WARN lines 0 (control-tested)
    agent / proxy ERROR lines 0 (control-tested)
    non-200 source-reporter access logs, fleet-wide, in window 0 (control-tested)
    collector receiver_refused / exporter_send_failed 0 / 0 (RSS 95–96 MiB of 2 Gi)
    alerts fired in #alerts during the window none
    end state mesh-dns 5/5 Ready, ready/watch_active = 1, records = 14 on all 5 nodes

    The one connection_error is background noise, not the residual race

    It landed on prober-2c48t (w05), mesh-domain, and the metric surfaced in the 15:34:00Z scrape, which is roll-10-adjacent (w05's close was 15:33:06.813Z). Three things say it is not the close() race:

    1. No hole. prober-2c48t's mesh-domain access log over 15:32:00–15:35:00Z holds 899 records for a 180 s window at 5/s — essentially nothing missing — and its largest gap anywhere in those 3 minutes is 0.703 s.
    2. connection_error is a post-resolution connect failure, a different class from the DNS datagram loss mesh-dns: add a lame-duck window on SIGTERM so the predecessor's SO_REUSEPORT socket keeps answering until the successor is serving (in-flight datagram loss on every roll, #726 root) #729 addresses. No DNS class moved with it.
    3. It recurs with no rolls at all. A second connection_error appeared on prober-pc8gf (w04) at 15:40:30Z, 7 minutes after the last roll, in a completely quiet cluster. Fleet rate on this prober generation is 2 in 222,124 requests (~1 in 111,000), roll or no roll.

    The pre-#728 comparison also still holds: 16–31 timeout on roughly 1 roll in 3 before the fix, so P(zero across 10 rolls | unchanged) ≈ 1.7%. This run adds the piece #728's validation explicitly could not supply — a direct measurement showing the hole itself is gone, not merely absorbed.

    Caveats

    • No dead-man's-switch heartbeat in the channel. #alerts is silent through the window (newest message 11:47:55Z, an AetherProberHTTPErrorBurst resolve from before the run), but I found no AetherAlertingDeadMansSwitch HEARTBEAT in ~48 h of channel history. Per the standing rule, a silent channel is corroboration only if the heartbeat posted within 24 h, so treat the zero-alerts line as weak. The pipeline did deliver a real firing/resolved pair at 11:42/11:47Z today, 3.3 h before the window, which is some evidence it was alive — but not a substitute for the canary.
    • The access-log queries were run against the VictoriaLogs datasource directly (/select/logsql/query, same LogsQL) rather than through the Grafana MCP, because the MCP caps results at 100 lines and a ±60 s window at 5 rq/s holds ~600 records. Truncated windows would have silently under-reported gaps. The mesh-dns log-line counts above did come through the MCP.
    • aether_mesh_dns_lame_duck_exits_total carries no pod-identifying label (only node, job, reason), so each generation's counter appears as the same series resetting to 1. That is fine for per-roll reads, but a window-total increase() over this metric will undercount badly. I graded from per-roll instant reads plus a 15 s-step range scan over the whole window to prove no deadline/signal series ever existed.
    • Load was prober-only, so this does not exercise the handoff under k6-level concurrency.

    Follow-up worth keeping

    The PR's own suggestion still stands and is cheap: an alert on increase(aether_mesh_dns_lame_duck_exits_total{reason="deadline"}[1h]) > 0 in the GitOps repo. Given the label shape above, sum by (node) (max_over_time(aether_mesh_dns_lame_duck_exits_total{reason="deadline"}[1h])) > 0 is the more robust expression.

    Leaving #729 open as requested. Cluster left as found: mesh-dns 5/5 Ready, nothing else rolled.

  2. bpalermo commented on Sep 6, 2026

    @bpalermo
    OwnerAuthor

    Closing stands (auto-closed by #734): the 10-roll validation above is a clean PASS — 50/50 successor exits, 0 deadline, lame-duck median 0.41 s / max 2.40 s (main-worker-02 is the consistently slow successor at 1.6–2.4 s, still far inside the 10 s cap), 0 timeout/dns_timeout across both paths on all probers, and the mesh-domain access-log gap at every one of the 50 closes (median 0.21 s, max 0.49 s) is indistinguishable from the cluster.local control. #726's 5.1 s hole is gone, not merely absorbed. Residual close() race not observed in 50 handoffs. Follow-up on the counter's per-generation reset filed separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions