Skip to content

Mesh DNS: decouple the resolver into a surge-capable daemon to make agent rolls hitless #578

Closed

Description

@bpalermo

Problem

The node agent's mesh-DNS resolver is in-process (miekg/dns on HOST_IP:18054, reached via the per-pod CNI :53 DNAT). Because it dies with the agent pod, every agent roll opens a per-node no-listener window where mesh-name lookups fail.

#577 (warm-start snapshot + bind-early + authoritative/never-forward) shipped and is deployed (talos rev 177). E2e on talos proved #577 works as designed — all 5 nodes warm-started records:11 from /host/var/lib/aether/registry/mesh-dns/records.json before binding, and the resolver bound before the xDS cache sync — but it did not make agent rolls hitless. A clean agent roll (fix on both sides) still cost ~329 failed mesh_dns probes (timeout + dns_error/ECONNREFUSED), statistically identical to the pre-fix soak.

Root cause

The agent DaemonSet is maxSurge:0, maxUnavailable:1 with no preStop, so on every node the old agent (and its resolver) is fully deleted before the new pod is created. warm-start/bind-early only make the new resolver correct and quick once it binds — they cannot cover the window where no agent process exists on the node. The dominant mesh_dns failure class during agent rolls is therefore the container-recreation gap, unaffected by #577.

Why decouple (chosen over a front cache)

The obvious zero-gap fix — maxSurge:1 + SO_REUSEPORT on :18054 (new resolver binds while old still serves) — is blocked on the full agent because the agent also binds host-path CNI/xDS UDS sockets that collide under surge.

Decoupling the resolver into its own tiny daemon removes that blocker: a standalone resolver has only the :18054 UDP/TCP socket — no UDS collision — so SO_REUSEPORT + maxSurge:1 becomes feasible and delivers true zero-gap handoff. It also keeps the exact, c-ares-sensitive resolver semantics (EDNS0 OPT echo, NODATA-for-non-A, authoritative flags) untouched (same code, relocated), and reuses #577's snapshot file as the agent→daemon feed. A front cache (CoreDNS/nodelocaldns serve_stale) was considered but rejected: it puts a foreign component with its own semantics in our most sensitive path and is only best-effort (cold-in-gap still misses).

Scope

  1. agent mesh-dns subcommand (mirrors agent edge / agent proxy-supervisor) that binds HOST_IP:18054 and serves from the meshdns resolver. No k8s API access — records come from the snapshot file, not an informer.
  2. Feed via file-watch: the daemon loads records.json at start (already the warm-start path) and reloads on change via fsnotify (reuse the agent/storage watch pattern). The agent keeps writing the snapshot from its capture reconciler but stops binding :18054.
  3. SO_REUSEPORT on the resolver's UDP+TCP listeners (via net.ListenConfig.Control + unix.SO_REUSEPORT, passed to dns.Server as PacketConn/Listener) so two daemons can co-bind during a surge.
  4. New aether-mesh-dns DaemonSet in charts/aether: host-network, updateStrategy.rollingUpdate.maxSurge:1, maxUnavailable:0, mounts the same host-persistent registry volume (read), runs agent mesh-dns. CNI DNAT target is unchanged (:18054).
  5. Chart version bump; tests; gazelle; format/lint.

Acceptance / e2e (talos)

  • Roll the aether-agent DaemonSet → mesh_dns prober tier stays ~0 errors through the roll (vs ~329 today). Baseline: sum(rate(aether_probe_requests_total{tier="mesh_dns",result!="success"}[5m])) by (node) flat at 0 across the roll.
  • Roll the new aether-mesh-dns DaemonSet → also hitless (surge + REUSEPORT overlap; confirm two pods co-bind :18054 during the roll).
  • Confirm the daemon reloads records on snapshot change (agent reconcile → file write → daemon fsnotify reload).

Follow-up to #577. The residual http_error cross-node drain path is tracked separately.

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