Skip to content

feat(mesh-dns): readiness gate so surge rolls are hitless - #580

Merged
bpalermo merged 1 commit into
mainfrom
meshdns-readiness-marker
Jul 22, 2026
Merged

bpalermo merged 1 commit into
mainfrom
meshdns-readiness-marker

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Follows #578 / #579.

Problem

#579 decoupled the aether-mesh-dns DaemonSet, but talos e2e showed its OWN rolls are not hitless (+130 failed mesh_dns probes). The 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. Old and new never overlap, so the handoff gaps.

Fix

Mirror the existing proxy-supervisor pattern: a pod-local ready-marker file + --readiness-check exec probe.

  • meshdns.Server: new WithReadyMarker(path) option. Start writes the marker file AFTER buildServers binds the UDP+TCP listeners and BEFORE the serve loop; removes it on ctx-cancel shutdown. Best-effort (logged, never fails Start).
  • agent mesh-dns: --ready-marker (default /run/aether/mesh-dns.ready) + --readiness-check (stats the marker, exits 0 iff present — the exec probe entrypoint, since the distroless image has no shell).
  • chart: writable /run/aether emptyDir, --ready-marker arg, and an exec readinessProbe (periodSeconds:2, failureThreshold:2). Chart.yaml 0.83.0 → 0.84.0.

The marker is intentionally pod-local (per-pod emptyDir): a network/tcpSocket probe to hostIP:18054 could be answered by the OTHER co-bound REUSEPORT socket and falsely mark the new pod ready before it has bound. A pod-local marker proves THIS process is serving, so the surge keeps the predecessor until the successor truly binds — then REUSEPORT gives a zero-gap handoff.

Tests

  • Server writes the marker after Start binds and removes it on ctx cancel; empty-path no-op.
  • --readiness-check returns non-zero when the marker is absent, nil (exit 0) when present.
  • Full bazel test //agent/... green; --config=ci (gocognit) clean; format-check clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR

#579)

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.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
@bpalermo
bpalermo merged commit 8a69756 into main Jul 22, 2026
14 checks passed
@bpalermo
bpalermo deleted the meshdns-readiness-marker branch July 22, 2026 10:25
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]>
bpalermo added a commit that referenced this pull request Jul 24, 2026
The aether-mesh-dns DaemonSet ran `command: ["/agent"] args: ["mesh-dns", …]`,
shipping and re-execing the ENTIRE agent binary (controller-runtime, xDS/
go-control-plane, CNI, SPIRE) just to serve a snapshot-fed DNS resolver — and
its readiness probe re-execed that huge binary every 5s.

Add a dedicated slim `//agent/cmd/mesh-dns` binary that imports ONLY the
`meshdns` resolver, snapshot fsnotify reload, resolv.conf upstream defaulting,
and push-only OTel telemetry. Verified via `bazel query somepath` that it pulls
in neither controller-runtime nor go-control-plane. To unblock that graph,
`common/file` now logs via stdlib slog instead of `ctrl.Log`, dropping its
controller-runtime edge (it's a low-level file util used everywhere).

The slim binary ships in the same agent image as an extra `/mesh-dns` layer
(no new image/publish pipeline this pass; #583's separate-image option is
deferred). The `agent mesh-dns` subcommand is retired — one code path now.

Chart: DaemonSet runs `/mesh-dns`; the readiness probe re-execs the slim
`/mesh-dns --readiness-check` (cheap) instead of the full agent, so period
15s / timeout 2s and resources drop to req 25m/32Mi lim 100m/64Mi.

Resolves #582: its proposed in-process httpGet probe is UNSAFE on a
host-network + maxSurge DaemonSet (two pods share the host netns → a health
port collides without SO_REUSEPORT or is REUSEPORT-ambiguous = the false-ready
#580 rejected). We keep the provably-pod-local ready-marker exec probe and
reclaim the ~250m fleet CPU by making the re-exec cheap via the slim binary.

Resolver semantics (EDNS0 echo, NODATA-for-non-A, authoritative never-forward,
REUSEPORT, marker-after-bind) and the surge/readiness guarantee are unchanged.

Closes #583


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 26, 2026
…TCP (#596)

Two deferred follow-ups from #586, in one PR because both live in the
resolver's server.go.

Wedge detection. The readiness gate wrote its pod-local marker once, right
after the listeners bound, and never re-verified that queries were being
answered. A resolver whose serve path wedged stayed Ready forever while the
CNI kept DNAT-ing every managed pod's :53 at it. A watchdog now exercises the
handler every 30s by calling ServeDNS in-process over an in-memory
ResponseWriter -- never over the network, because SO_REUSEPORT means a query
to HOST_IP:18054 can be answered by the PEER pod during a surge, the exact
false-ready trap #580 rejected a tcpSocket probe over. The probe name is the
reserved "_selfcheck._aether.<meshDomain>": under the mesh domain so it takes
the authoritative path and never depends on kube-dns, and spelled with
underscore labels that can never be a DNS-1123 namespace/Service, so the
answer is deterministic (NXDOMAIN when populated, SERVFAIL while cold) on a
cluster with zero mesh services. Three consecutive failures remove the ready
marker so the exec probe flips the pod NotReady and the rollout machinery can
react; a single pass restores it. The watchdog starts only after the bind has
already written the marker, so it can never flap a starting pod.

Forward-path transport. forward() used one dns.Client pinned to "udp", so a
query that arrived over TCP -- reachable in production, the CNI DNATs TCP :53
too -- was relayed over UDP and could come back TC=1, recorded as a clean
"forwarded" while the client looped. There are now two clients: TCP in means
TCP out, and a truncated UDP reply is re-fetched over TCP and re-packed to the
client's advertised size. Both clients state DialTimeout/ReadTimeout/
WriteTimeout explicitly at the 2s that miekg/dns was applying implicitly.

New instruments: self_check_total{result}, last_answered_timestamp_seconds
(stamped by real traffic too, so a busy resolver never looks idle),
responses_truncated_total, and a proto=udp|tcp attribute on the query counter.
The test fake ResponseWriter is retired in favour of the production
memResponseWriter the watchdog uses.

Follows #586.


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

Co-authored-by: Claude <[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.

1 participant