Repository navigation
feat(mesh-dns): close the observability gaps (#586) - #587
Merged
Merged
Conversation
The mesh-DNS resolver is a standalone DaemonSet on the critical path for
EVERY managed pod's DNS (the CNI DNATs all UDP+TCP :53 to HOST_IP:18054),
yet it shipped one counter and no logs at all.
Snapshot freshness envelope + agent heartbeat. The on-disk snapshot is now
{writtenAt, generation, records}; ReadSnapshot still accepts the legacy
bare map (back-filling writtenAt from the file mtime) so an in-place
upgrade never starts the resolver cold. Because the writer is event-driven
(no short SyncPeriod), a new MeshDNSHeartbeat runnable re-stamps the
snapshot every 60s even when nothing changed, so snapshot age measures the
WRITER's liveness rather than cluster churn. The generation advances only
on a content change, and the heartbeat never writes before the first
projection (an empty table would NXDOMAIN the whole mesh).
New instruments: snapshot_age_seconds, snapshot_written_at_seconds,
records, snapshot_generation, watch_active, upstreams_configured and ready
(observable gauges, exported from a registered callback that copies state
out from under the Server's RWMutex), snapshot_reloads_total{result} and
query.duration{result} with DNS-appropriate explicit buckets.
Logs now ship over OTLP: a LoggerProvider bridged into the daemon's slog
via otelslog, plus Go runtime metrics. common/telemetry/setup is
deliberately NOT imported — it reaches controller-runtime and would undo
the slim binary (#583); only otlploggrpc + sdklog are mirrored locally.
Empty upstreams is a node-wide DNS outage (every non-mesh query becomes a
forward_error) and was announced at INFO as "upstreams=[]". It is now an
ERROR plus upstreams_configured=0; the fail-open behaviour is unchanged.
Chart: NODE_NAME fieldRef so k8s.node.name is the node name, not its IP.
Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
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.
Closes #586.
The mesh-DNS resolver is a standalone DaemonSet on the critical path for every managed pod's DNS (the CNI DNATs all UDP+TCP
:53toHOST_IP:18054), yet it shipped one counter and no logs at all. All 5 scope items in one PR.1. Snapshot freshness envelope + agent heartbeat
The on-disk snapshot becomes a versioned envelope:
{"writtenAt": 1753440000, "generation": 42, "records": {"<ns>/<svc>": "<ip>"}}ReadSnapshotstill accepts the legacy bare map ({"<ns>/<svc>":"<ip>"}) and back-fillswrittenAtfrom the file mtime, so an in-place upgrade never starts the resolver cold. The envelope is tried first and only accepted when it actually carries arecordsobject, so a legacy file whose service keys collide with envelope field names still decodes.WriteSnapshot(path, records, generation)stampswrittenAt=nowand carries the caller's generation.SyncPeriod→ 10h resync), so a healthy quiet cluster would look stale. A newcapture.MeshDNSHeartbeatcontroller-runtime Runnable re-stamps the snapshot everyMeshDNSHeartbeatInterval(60s). Snapshot age therefore measures the writer's liveness, not cluster churn.generationadvances only on a content change, so a heartbeat rewrite is distinguishable from a real update.--mesh-dnsis on, and the rewrite is itself inert when the snapshot path is empty.NeedLeaderElection() == false(every node must re-stamp its own snapshot).2. New instruments
Observable gauges (one registered callback; state copied out from under the
ServerRWMutex, never held across the export):aether.mesh_dns.snapshot_age_secondsaether.mesh_dns.snapshot_written_at_secondsaether.mesh_dns.recordsaether.mesh_dns.snapshot_generationaether.mesh_dns.watch_activeaether.mesh_dns.upstreams_configuredaether.mesh_dns.readyaether.mesh_dns.snapshot_reloads_total{result}success/missing/parse_error/read_erroraether.mesh_dns.query.duration{result}query.durationuses explicit buckets from 100µs (a mesh hit is an in-memory map read) to 5s; the OTel defaults would collapse the whole mesh path into bucket 0. Reload results are classified via a newErrSnapshotParsesentinel +fs.ErrNotExist. Everything stays nil-safe.3. Logs over OTLP + runtime metrics
SetupTelemetrynow returns aTelemetrycarrying anotelsloghandler over an OTLP-gRPCsdklog.LoggerProvider, fanned into the daemon's slog alongside stderr (log.NewLoggerWithHandler). Before this, mesh-DNS logs existed only as pod stdout and died on every roll — which mattered because several failure modes' only signal is a log line.common/telemetry/setupis deliberately not imported (it reaches controller-runtime and would undo the slim binary, #583) — onlyotlploggrpc+sdklogare mirrored locally.runtime.Start()adds Go runtime metrics (goroutine leaks on the TCP path were invisible). Both are non-fatal degradations surfaced asTelemetry.Warningsand logged at WARN; instrument-creation failures now log a WARN instead ofnewMetricssilently returning nil.4. Empty-upstreams fix
With no upstream, every non-mesh query (cluster.local and external) becomes a
forward_error— a node-wide DNS outage — previously announced at INFO asupstreams=[]. Now ERROR with an explicit message, plusupstreams_configured=0. Fail-open behaviour is unchanged (mesh names still resolve).5. Chart
NODE_NAMEfromfieldRef: spec.nodeName, used fork8s.node.nameinOTEL_RESOURCE_ATTRIBUTES(was$(HOST_IP), which never joined with the agent's node label).HOST_IPis kept for the bind address. No new flags. Chart bumped 0.86.0 → 0.87.0.Slim-graph proof
Also empty for
@io_k8s_sigs_controller_runtime//...(any target) and@io_k8s_api//....Validation
bazel test //...— 78/78 pass;bazel build //agent/... //charts/...green.bazel build --config=ci //agent/... //common/...green (gocognit ≤ 15).bazel run //:format+make format-checkclean.Deviations
aether.mesh_dns.snapshot_generation, which is what makes "the agent re-stamped freshness" distinguishable from "the record table actually changed" at query time.ReloadFromSnapshot's success log dropped from INFO to DEBUG — with a 60s heartbeat it would otherwise emit a per-node INFO line every minute, now shipped over OTLP.🤖 Generated with Claude Code
https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR