Repository navigation
fix(mesh-dns): close the agent-roll cold window (warm-start + authoritative) - #577
Merged
Merged
Conversation
…tative) The soak's mesh_dns prober tier caught a 0.509% roll-correlated failure (timeout dominant, plus dns_error/dns_nxdomain) rooted in two windows on agent restart: 1. Bind gap -> timeout: controller-runtime starts plain Runnables only AFTER informer caches sync, so the in-process resolver's ListenAndServe on HOST_IP:18054 was delayed; DNAT'd :53 packets hit a closed port. 2. Empty-records-forward -> dns_error/nxdomain: with an empty record table a real mesh name missed and was FORWARDED to kube-dns, which has no aether.internal zone and answers SERVFAIL/NXDOMAIN. Fix 1 (warm-start + early bind): - Persist the records table to a host-persistent snapshot on every SetRecords (atomic write via common/file) and warm-load it in NewServer before binding, so a fresh agent answers mesh names from last-known ClusterIPs within ms of boot. The snapshot lives in a dedicated subdir under the CNI registry hostPath (survives a rolling pod restart, stays out of the CNI pod store's top-level *.json scan). New --mesh-dns-snapshot-path flag, defaulted there. - Bind the resolver directly in a goroutine (not m.Add), off the cache-gated Runnable group, so its UDP+TCP sockets open at process start. Start still honors ctx.Done for graceful miekg/dns Shutdown; a bind error crashes the agent so the DaemonSet restarts it. Fix 2 (authoritative mesh domain): - A name under .meshDomain that misses the record table is NEVER forwarded. It is answered locally: NXDOMAIN once records have ever been populated (a real miss), SERVFAIL (retryable) while still cold (never populated). Only genuinely non-mesh names still forward upstream. EDNS0 echo + NODATA-for-non-A behavior for hits is unchanged. - New metric result labels: nxdomain (authoritative mesh miss) and cold (SERVFAIL before records populated), nil-safe. Serving stale is safe: ClusterIPs are stable for a Service's lifetime; worst case a since-deleted service resolves to a dead VIP for one reconcile (fast self-healing connection error), strictly better than timeout/NXDOMAIN. No chart template change needed: the snapshot subdir lives under the already-unconditionally-mounted cni-registry-dir hostPath. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
Fold "never forward the mesh domain" fully into the resolver: isMeshName now matches ANY name under .meshDomain (suffix-only), not just a well-formed <svc>.<ns>. A malformed spelling under the zone (wrong label count, e.g. the flat <svc>.<meshDomain>) is answered authoritative NXDOMAIN in serveMesh — regardless of readiness, since a structurally invalid name can never become valid — instead of leaking to kube-dns for a slow upstream round-trip that surfaces as roll-correlated dns failures. Only genuinely non-mesh names (cluster.local, external) and the bare apex still forward. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
This was referenced Jul 22, 2026
bpalermo
added a commit
that referenced
this pull request
Jul 22, 2026
…579) The mesh-DNS resolver was in-process in the node agent, so every agent roll opened a per-node window with no listener on the :53 DNAT target (HOST_IP:18054) — #577's warm-start/bind-early could only make the NEW resolver fast once it bound, not cover the container-recreation gap. Decouple the resolver into a standalone aether-mesh-dns DaemonSet. It owns :18054 alone (only a UDP/TCP socket, no host-path UDS to collide), so maxSurge:1 + SO_REUSEPORT lets the successor co-bind while the predecessor still serves — a truly hitless handoff across its own rolls, which an agent roll could never do. Records flow agent -> snapshot file -> daemon (fsnotify), reusing #577's snapshot as the feed. The CNI DNAT target is unchanged. - meshdns: extract Read/WriteSnapshot package funcs (shared by the agent persist path and the Server load); add ReloadFromSnapshot for the daemon's fsnotify handler; add WithReusePort so Start binds UDP+TCP with SO_REUSEPORT+SO_REUSEADDR (net.ListenConfig.Control) and serves via ActivateAndServe. Resolver semantics (EDNS0 echo, NODATA, never forward mesh, authoritative) unchanged. - agent mesh-dns subcommand: binds HOST_IP:18054, loads the snapshot, watches its PARENT dir (survives the atomic rename, like agent/storage) and reloads on debounced create/write/rename of the snapshot file; push-only OTel metrics like the proxy-supervisor. No k8s API access. - agent: wireMeshDNS is persist-only now — the capture sink writes the snapshot via meshdns.WriteSnapshot; the agent no longer binds :18054. - chart: new aether-mesh-dns DaemonSet (host-net, maxSurge:1/ maxUnavailable:0, registry hostPath read-only, reuses the agent SA, no RBAC), gated by the same agent.meshDns toggle; agent container drops the now-unused HOST_IP env + --mesh-dns-upstream flag. Chart 0.83.0. Closes #578 Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Jul 25, 2026
) On a FRESH cluster the resolver daemon usually starts before the agent's first projection. The snapshot dir is created lazily by the agent, and the daemon mounts that volume read-only, so it found nothing to watch, logged "records will not reload until restart", and then served nothing FOREVER -- while reporting Ready 1/1, because the ready-marker is written after bind, not after records load. This is why the multi-cluster e2e has been red since 07-22 (#589) and why talos never showed it: there the dir has existed since #577, so the race cannot occur on an established cluster. Only a fresh install hits it, and kind is fresh every run. Two fixes, one per side of the race: - Agent: EnsureSnapshotDir at startup rather than on first write, so the dir exists before the daemon can look for it. Non-fatal. - Daemon: retry establishing the watch instead of giving up for the process lifetime, and poll ReloadFromSnapshot while blind so records land even if fsnotify never works. A missing dir is now WARN, not ERROR. The second is the one that matters: it fixes the class, surviving any startup ordering, agent restart, or volume remount. Refs #589. Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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
The soak's
mesh_dnsprober tier caught a 0.509% roll-correlated failure (timeout dominant, plusdns_error/dns_nxdomain) on the node agent's in-process mesh DNS resolver. Two windows open on every agent restart:ListenAndServeonHOST_IP:18054was delayed until cache sync. Per-pod nftables:53DNAT'd packets hit a closed port → client timeout.{}; until the first reconcile a real mesh name missed and was forwarded to kube-dns, which has noaether.internalzone → SERVFAIL/NXDOMAIN. Forwarding a mesh-domain name is never correct — the resolver is authoritative for the mesh domain.Fix 1 — warm-start from a disk snapshot + bind early
recordstable to a host-persistent snapshot (atomic write viacommon/file) on everySetRecords, and warm-load it inNewServerbefore binding, so a fresh agent answers mesh names from last-known ClusterIPs within ms of process start..../registry/mesh-dns/records.json) under the already-mounted CNI registry hostPath: survives a rolling pod restart, and stays out of the CNI pod store's top-level*.jsonscan (setupStorage/loadAllunmarshals every top-level.jsonthere as aCNIPod; a subdir is skipped). New--mesh-dns-snapshot-pathflag, defaulted there.m.Add), off the cache-gated Runnable group, so its UDP+TCP sockets open at process start.Startstill honorsctx.Donefor graceful miekg/dnsShutdown; a bind error crashes the agent so the DaemonSet restarts it.Fix 2 — never forward the mesh domain; authoritative answer + readiness gate
.meshDomainthat misses the record table is never forwarded. Answered locally: NXDOMAIN once records have ever been populated (a real miss), SERVFAIL (retryable) while still cold (never populated). Only genuinely non-mesh names still forward upstream.aether.mesh_dns.queries:nxdomain(authoritative mesh miss) andcold(SERVFAIL before records populated), nil-safe.Serving stale is safe: ClusterIPs are stable for a Service's lifetime; worst case a since-deleted service resolves to a dead VIP for one reconcile (fast self-healing connection error), strictly better than timeout/NXDOMAIN.
Testing
bazel test //agent/...— all 26 targets pass (new meshdns cases: warm-start load, missing-snapshot cold, SetRecords persist round-trip, cold→SERVFAIL vs ready→NXDOMAIN, mesh names never forwarded, non-mesh still forwarded, hit answers with EDNS0, non-A NODATA).make format-checkclean;--config=cilint (gocognit ≤15 gate) green on touched packages.Chart
No template change needed — the snapshot subdir lives under the already-unconditionally-mounted
cni-registry-dirhostPath, so no Chart.yaml bump.🤖 Generated with Claude Code
https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR