Repository navigation
feat(mesh-dns): readiness gate so surge rolls are hitless - #580
Merged
Merged
Conversation
#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
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]>
This was referenced Jul 25, 2026
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]>
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.
Follows #578 / #579.
Problem
#579 decoupled the
aether-mesh-dnsDaemonSet, but talos e2e showed its OWN rolls are not hitless (+130 failedmesh_dnsprobes). The DaemonSet has no readiness probe, so withmaxSurge:1/maxUnavailable:0k8s marks the new pod Ready the instant its container is Running — before it binds:18054— and retires the old pod before theSO_REUSEPORTco-bind ever engages. Old and new never overlap, so the handoff gaps.Fix
Mirror the existing
proxy-supervisorpattern: a pod-local ready-marker file +--readiness-checkexec probe.meshdns.Server: newWithReadyMarker(path)option.Startwrites the marker file AFTERbuildServersbinds the UDP+TCP listeners and BEFORE the serve loop; removes it on ctx-cancel shutdown. Best-effort (logged, never failsStart).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)./run/aetheremptyDir,--ready-markerarg, and an execreadinessProbe(periodSeconds:2,failureThreshold:2).Chart.yaml0.83.0 → 0.84.0.The marker is intentionally pod-local (per-pod
emptyDir): a network/tcpSocket probe tohostIP:18054could 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
Serverwrites the marker afterStartbinds and removes it on ctx cancel; empty-path no-op.--readiness-checkreturns non-zero when the marker is absent, nil (exit 0) when present.bazel test //agent/...green;--config=ci(gocognit) clean; format-check clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR