Skip to content

fix(mesh-dns): don't wedge when the snapshot dir doesn't exist yet - #592

Merged
bpalermo merged 1 commit into
mainfrom
fix/mesh-dns-snapshot-dir-race
Jul 25, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/mesh-dns-snapshot-dir-race

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Root cause of the multi-cluster e2e failing since 07-22 (#589), found via the diagnostics added in #590.

The bug

Every mesh-dns pod in both kind clusters logged:

ERROR "failed to watch mesh-DNS snapshot dir; records will not reload until restart"
      error: "no such file or directory"
      dir:   "/host/var/lib/aether/registry/mesh-dns"

The chain:

  1. The mesh-dns/ subdir is created lazily by the agent, on its first WriteSnapshot.
  2. The daemon mounts that volume readOnly: true — it cannot create the dir itself.
  3. On a fresh cluster the daemon wins the race, finds no dir, and its fsnotify watch fails permanently.
  4. It still reports Ready 1/1 — the ready-marker is written after bind, not after records load. Kubernetes sees a healthy pod that can answer nothing, so every mesh name fails.

This is a production bug, not a kind artifact. It's invisible on any established cluster (on talos the dir has existed since #577), and only bites a fresh install — which is what every kind e2e run is. No amount of soaking on an existing cluster could have caught it.

The fix — one per side of the race

  • Agent: EnsureSnapshotDir at startup instead of on first write, so the dir exists before the daemon looks. Non-fatal.
  • Daemon: retry establishing the watch rather than giving up for the process lifetime, and poll ReloadFromSnapshot while blind so records land even if fsnotify never works. A missing dir is now WARN, not ERROR.

The daemon half is the one that matters: it fixes the class, surviving any startup ordering, agent restart, or volume remount.

Verification

bazel test //agent/... 27/27 · --config=ci (gocognit) clean · format clean · slim dep graph re-proven (0 paths to controller-runtime and go-control-plane). New tests cover EnsureSnapshotDir and watcher recovery once the dir appears.

e2e verification to follow on this branch.

Refs #589.

🤖 Generated with Claude Code

On a FRESH cluster the resolver daemon usually starts before the agent's
first projection. The snapshot dir is created lazily by the agent, and the
daemon mounts that volume read-only, so it found nothing to watch, logged
"records will not reload until restart", and then served nothing FOREVER --
while reporting Ready 1/1, because the ready-marker is written after bind,
not after records load.

This is why the multi-cluster e2e has been red since 07-22 (#589) and why
talos never showed it: there the dir has existed since #577, so the race
cannot occur on an established cluster. Only a fresh install hits it, and
kind is fresh every run.

Two fixes, one per side of the race:
  - Agent: EnsureSnapshotDir at startup rather than on first write, so the
    dir exists before the daemon can look for it. Non-fatal.
  - Daemon: retry establishing the watch instead of giving up for the
    process lifetime, and poll ReloadFromSnapshot while blind so records
    land even if fsnotify never works. A missing dir is now WARN, not ERROR.

The second is the one that matters: it fixes the class, surviving any
startup ordering, agent restart, or volume remount.

Refs #589.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
@bpalermo
bpalermo merged commit e778522 into main Jul 25, 2026
21 checks passed
@bpalermo
bpalermo deleted the fix/mesh-dns-snapshot-dir-race branch July 25, 2026 20:38
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