Repository navigation
fix(mesh-dns): detect a wedged resolver and forward TCP queries over TCP - #596
Merged
Merged
Conversation
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. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
This was referenced Jul 26, 2026
bpalermo
added a commit
that referenced
this pull request
Jul 26, 2026
…598) Completes the deferred qtype/nodata half of the mesh-DNS query-metric breakdown. #596 already gave aether.mesh_dns.queries its proto attribute and the responses_truncated_total counter; this is the rest. The `answered` result conflated two operationally different things: a real A hit, and the NODATA reply a known mesh name gets for a non-A type (AAAA), which exists so the name consistently EXISTS for c-ares. A healthy mesh shows a steady NODATA trickle from the AAAA half of every dual-stack lookup, so conflated, NODATA rising against real hits — clients failing over to IPv6, or a record table that stopped producing usable A records — is invisible. They are now separate result values. NODATA still counts as an answer for last_answered_timestamp_seconds: it is an authoritative reply produced from the record table by a handler that ran end to end. The new qtype attribute is BUCKETED, never raw. DNS defines ~90 query types and the CNI DNATs every managed pod's :53 straight at this resolver, so an arbitrary client could otherwise inflate the counter's series count at will. Everything unrecognised collapses to `other`, bounding the counter at 8 qtype x 6 result x 2 proto = 96 series per node. qtype is deliberately NOT added to the duration histogram: 15 explicit buckets make each extra dimension expensive, and latency here is decided by the path taken — which `result` already names — not by the type asked for. Metrics-only: no resolver semantics change (EDNS0 echo, NODATA-for-non-A, never-forward-the-mesh-zone, SO_REUSEPORT, the self-check watchdog, TCP forwarding and the snapshot envelope are all untouched). 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.
Two of the follow-ups explicitly deferred by #586, in one PR because both live in the resolver's
server.go.Fix 1 — wedge detection
The readiness gate wrote its pod-local marker once, right after the listeners bound (
Start→writeReadyMarker), and never re-verified that queries were actually being answered. A resolver whose serve path wedged stayed Ready forever while the CNI kept DNAT-ing every managed pod's:53at something that answered nothing.A watchdog (
agent/internal/meshdns/selfcheck.go) now exercises the handler every 30s by callingServeDNSin-process over an in-memorydns.ResponseWriter.Why not a network self-query: the daemon binds
HOST_IP:18054withSO_REUSEPORTso a surge successor can co-bind, which means a query to that address can be answered by the peer pod — the exact false-ready trap #580 rejected atcpSocketprobe over. Only an in-process call can prove this process answers.Why this probe name (
_selfcheck._aether.<meshDomain>.):_, which is not a legal DNS-1123 Kubernetes namespace or Service name, so the record table can never hold this key. The answer is therefore deterministic on a cluster with zero mesh services: NXDOMAIN once records are populated, SERVFAIL while still cold. Both are authoritative and both prove the handler ran end to end (name parse → record-table lock → reply write);<svc>.<ns>name, so it goes through the record-table lookup — a wedge that is a stucks.muis caught, not skipped.Each check runs on its own goroutine and is awaited with a 5s timeout: a wedged handler never returns, and blocking the watchdog on it would defeat the point. Three consecutive failures remove the ready marker so the exec readiness probe flips the pod NotReady and the surge/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.
Fix 2 — UDP-only forward client truncating TCP-originated queries
forward()used a single&dns.Client{Net: "udp"}. Since the CNI DNATs TCP:53as well, a query that arrived over TCP — from a client that had already decided it wants an answer too big for a datagram — was relayed over UDP and could come back withTC=1, which we recorded as a cleanforwardedwhile the client looped or failed.ResponseWriter'sRemoteAddr()(*net.TCPAddrvs*net.UDPAddr);TC=1reply is passed through rather than a SERVFAIL;Netis mutated under concurrent serve goroutines;DialTimeout/ReadTimeout/WriteTimeoutare now explicit. miekg/dns was already applying an implicit 2s (its unexporteddnsTimeout) to each; this pins the same value so the bound is visible and cannot move under a dependency bump.Metrics
aether.mesh_dns.self_check_total{result=ok|fail}aether.mesh_dns.last_answered_timestamp_secondsaether.mesh_dns.responses_truncated_totalTC=1and required the TCP retryaether.mesh_dns.queries{result,proto}proto=udp|tcpattribute (the duration histogram keepsresultonly, to avoid doubling 15 buckets)Notes
charts/change: the existing exec readiness probe already stats the marker, which is exactly the lever the watchdog pulls.fakeResponseWriteris retired in favour of the productionmemResponseWriterthe watchdog uses — one implementation, not two.somepath(//agent/cmd/mesh-dns:mesh-dns, @io_k8s_sigs_controller_runtime//...)and the@com_github_envoyproxy_go_control_plane//...equivalent are both empty.Follows #586.
🤖 Generated with Claude Code
https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR