Skip to content

mesh-dns: replace exec-marker readiness probe with in-process /healthz (reclaim ~250m fleet CPU) #582

Closed as not planned

Description

@bpalermo

Problem

The aether-mesh-dns daemon's readiness probe (added #580, tuned #581) execs /agent mesh-dns --readiness-check, which re-runs the full /agent binary every periodSeconds (5s) to stat a pod-local marker. The binary is the whole agent (controller-runtime, xDS, …), so each cold start burns ~150–200ms of CPU.

Measured (talos rev 180 / chart 0.85.0, live)

  • mesh-dns daemon: ~46–56m CPU, 12–15Mi RSS per node.
  • The ~50m CPU is almost entirely the probe re-exec, not DNS serving (a <svc>.<ns> map lookup at mesh QPS is microseconds). Math: ~180ms cold-start × (1/5s) ≈ ~36–40m avg — matches.
  • Across the 5-node fleet that's ~250m CPU spent health-checking, and it's why fix(mesh-dns): readiness probe timeout + CPU headroom (unblock surge rollout) #581 had to inflate limits to cpu 300m / mem 128Mi (burst headroom for the transient second /agent process).

Proposal

Replace the exec probe with an in-process HTTP /healthz served by the daemon on a plain 127.0.0.1:<port> listener (NOT :18054, NOT SO_REUSEPORT), returning 200 once both DNS listeners are bound (i.e. where the ready-marker is written today). Switch the DaemonSet to an httpGet readiness probe.

  • Zero re-exec → CPU drops from ~50m to single-digit m; limits can come back down toward the daemon's real footprint (~15Mi / few m).
  • No REUSEPORT false-ready ambiguity — the reason a tcpSocket probe on :18054 was rejected (kubelet could hit the peer pod's co-bound socket during a surge). A dedicated non-REUSEPORT localhost health port is pod-local, so it proves this process is serving. Keep the surge/readiness guarantee from feat(mesh-dns): readiness gate so surge rolls are hitless #580.

Scope

  • agent/internal/meshdns (or the mesh-dns subcommand): start a tiny HTTP health listener on 127.0.0.1:<healthPort>; return 200 after buildServers binds (reuse the same signal as the current ready-marker; the marker/--readiness-check path can be removed).
  • charts/aether/templates/mesh-dns-daemonset.yaml: httpGet readiness probe on the health port; drop the emptyDir marker volume; lower meshDnsDaemon.resources (the re-exec headroom is no longer needed). Chart version bump.
  • Keep the ready-after-bind semantics so maxSurge:1 still waits for a true bind (the feat(mesh-dns): readiness gate so surge rolls are hitless #580 guarantee).

Context

Follows #578 (decouple), #580 (readiness gate), #581 (probe timeout+CPU headroom). Surfaced while assessing a Go→Rust rewrite of the resolver (rejected — footprint is already tiny; the only real cost was this probe). Complements the slim-binary follow-up (separate issue).

Activity

  1. bpalermo commented on Jul 24, 2026

    @bpalermo
    OwnerAuthor

    Reframing — the in-process httpGet approach is unsafe here; the CPU goal is being met via #583 instead

    While implementing, the proposed in-process /healthz + httpGet probe turned out to be unsafe on this host-network + maxSurge:1 DaemonSet: during a surge the old and new pods share the host network namespace, so any health port either

    • collides without SO_REUSEPORT (the new pod can't bind it while the old holds it → the surge wedges), or
    • is REUSEPORT and ambiguous — kubelet's probe can be routed to the peer pod's socket, i.e. the exact false-ready failure that feat(mesh-dns): readiness gate so surge rolls are hitless #580 deliberately chose the pod-local marker over tcpSocket to avoid.

    A port-based check can't be provably pod-local on host-network+surge, so switching to httpGet would regress the #580 readiness guarantee.

    Root cause of the ~50m/node (~250m fleet) CPU is not the probe mechanism — it's re-execing the full /agent binary (~180ms cold-start) every 5s. #583 (slim /mesh-dns binary) makes that same pod-local marker check cheap (~10–20ms cold-start), reclaiming the CPU without the correctness regression. The implementing PR also bumps periodSeconds 5→15 to further cut churn and lowers meshDnsDaemon.resources.

    Closing as resolved-by-#583 (the httpGet mechanism is abandoned; the CPU-reclaim goal is delivered there).

  2. added a commit that references this issue on Jul 24, 2026
    8e1f2e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions