Skip to content

feat(mesh-dns): decouple resolver into a surge-capable daemon (#578) - #579

Merged
bpalermo merged 1 commit into
mainfrom
feat/meshdns-daemon-578
Jul 22, 2026
Merged

bpalermo merged 1 commit into
mainfrom
feat/meshdns-daemon-578

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

What

Decouples the node agent's in-process mesh-DNS resolver into its own standalone, surge-capable aether-mesh-dns DaemonSet, so agent rolls no longer gap mesh DNS. Builds directly on #577 (warm-start snapshot at /host/var/lib/aether/registry/mesh-dns/records.json).

Why

The agent DaemonSet is maxSurge:0, maxUnavailable:1 with no preStop, so every agent roll deletes the old agent (and its in-process resolver) before the new pod exists — a per-node no-listener window on the :53 DNAT target. #577's warm-start/bind-early only make the new resolver correct once it binds; they cannot cover the container-recreation gap.

The obvious zero-gap fix (maxSurge:1 + SO_REUSEPORT) is blocked on the full agent because it also binds host-path CNI/xDS UDS sockets that collide under surge. A standalone resolver has only the :18054 UDP/TCP socket — no UDS collision — so SO_REUSEPORT + maxSurge:1 becomes feasible and delivers a truly hitless handoff.

Changes

  • meshdns: extracted ReadSnapshot/WriteSnapshot package funcs (shared by the agent persist path and Server's load); added ReloadFromSnapshot() for the daemon's fsnotify handler; added WithReusePort option — Start then binds UDP+TCP with SO_REUSEPORT+SO_REUSEADDR via net.ListenConfig.Control and serves via ActivateAndServe. Resolver semantics (EDNS0 echo, NODATA-for-non-A, never-forward-mesh, authoritative) are byte-for-byte unchanged.
  • agent mesh-dns subcommand (agent/internal/cmd/meshdns.go, mirrors proxy-supervisor): binds HOST_IP:18054, loads the snapshot, watches its parent dir so the agent's atomic-rename write is caught (fsnotify loses the watch on the replaced inode — same as agent/storage), reloads on debounced create/write/rename of the snapshot file. Push-only OTel metrics like the supervisor. No k8s API access.
  • Agent persist-only: wireMeshDNS no longer serves DNS; the capture sink writes the snapshot via meshdns.WriteSnapshot. Still gated by --mesh-dns.
  • Chart: new aether-mesh-dns DaemonSet (host-network, maxSurge:1/maxUnavailable:0, registry hostPath mounted read-only, reuses the agent ServiceAccount, no RBAC, drops all caps — binds 18054 > 1024 so no NET_BIND_SERVICE). Gated by the same agent.meshDns toggle (default-on ⇒ daemon default-on). Agent container drops the now-unused HOST_IP env + --mesh-dns-upstream flag; the CNI DNAT (init container) is unchanged. Chart bumped 0.82.0 → 0.83.0.

Tests

  • New: SO_REUSEPORT co-bind (two Servers bind the same 127.0.0.1:<port>, both answer), snapshot Read/Write round-trip, ReloadFromSnapshot picks up a rewritten file. Existing server_test.go + capture reconciler + cmd tests stay green.
  • bazel test //... (excl. integration): 72/72 pass. make format-check clean. gocognit gate green (--config=ci). Chart lint + template tests pass.

Acceptance (talos, follow-up)

Roll aether-agent → mesh_dns prober tier should stay ~0 errors through the roll (vs ~329 today). Roll aether-mesh-dns → also hitless (surge + REUSEPORT overlap; two pods co-bind :18054). Confirm the daemon reloads on snapshot change.

Closes #578

🤖 Generated with Claude Code

https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR

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

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
@bpalermo
bpalermo merged commit 9c54cd6 into main Jul 22, 2026
14 checks passed
@bpalermo
bpalermo deleted the feat/meshdns-daemon-578 branch July 22, 2026 10:01
bpalermo added a commit that referenced this pull request Jul 22, 2026
#579) (#580)

The decoupled aether-mesh-dns DaemonSet has no readiness probe, so with
maxSurge:1/maxUnavailable:0 k8s marks the new pod Ready the instant its
container is Running — before it binds :18054 — and retires the old pod
before the SO_REUSEPORT co-bind ever engages (+130 failed mesh_dns probes
in talos e2e).

Mirror the proxy-supervisor pattern: a pod-local ready-marker file the
resolver writes only after its UDP+TCP listeners are bound, plus an exec
readiness probe (agent mesh-dns --readiness-check) that stats it. The marker
must be pod-local (per-pod emptyDir) — a network probe to hostIP:18054 could
be answered by the OTHER co-bound REUSEPORT socket and falsely mark the new
pod ready. This holds the predecessor until the successor truly serves, so
the sockets overlap and REUSEPORT gives a zero-gap handoff.

- meshdns.Server: WithReadyMarker option; Start writes the marker after
  buildServers binds and removes it on ctx shutdown (best-effort, never fatal).
- agent mesh-dns: --ready-marker + --readiness-check flags (exec probe mode).
- chart: writable /run/aether emptyDir, --ready-marker arg, exec readinessProbe
  (periodSeconds 2, failureThreshold 2); Chart.yaml 0.83.0 -> 0.84.0.


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 22, 2026
…581)

The mesh-dns readiness probe re-execs the full /agent binary (distroless
image, no shell), whose cold start under the daemon's 50m CPU request/100m
limit exceeds the 1s default probe timeout — so the surge pod never reported
Ready and maxUnavailable:0 wedged the rollout (found on talos e2e: probe
"command timed out after 1s" x136, pod stuck 0/1 though bound + serving).

Bump the probe to timeout 5s / period 5s / failureThreshold 3, and give the
daemon CPU burst (limit 100m→300m) + memory (64Mi→128Mi) headroom for the
transient second /agent process the exec spawns. Marker semantics unchanged.

Follows #578/#579/#580.


Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant