Repository navigation
fix(agent): re-assert the aether-cni conflist entry when a competing writer strips it (#645) - #650
Merged
Merged
Conversation
The aether-cni entry is appended to another CNI's conflist by exactly one component today — the cni-install init container — and the agent cannot reuse that logic: cni/internal/install is internal to //cni. Move the mutation (insert/replace the aether entry, kubelet's config-file resolution, the marshalling shape) into the importable aethermesh.dev/cni/conflist, so the upcoming agent-side re-assert loop (#645) shares ONE implementation with the installer and the on-disk shape can never diverge between them. Adds the parse-side helpers that loop needs (AetherEntry, HasAether, HasBasePlugin, ActivePath). No behavior change: the installer keeps writing exactly what it wrote, and the moved tests move with it. cni/internal/util/plugin.go had no other caller and goes away; the /etc/cni/net.d path joins common/constants next to the registry path, as both the CNI and the agent now need it. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…writer strips it (#645) cni-install appends aether's chained plugin entry to the primary CNI's conflist ONCE, from the agent pod's init container. kube-flannel's init container does an unconditional `cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conflist` on every flannel pod recreation — which Talos triggers on every bootstrap-manifest re-sync (boot, apply-config, k8s upgrade). aether appends once, flannel overwrites forever, so aether always loses eventually: on 2026-08-29 a manifest re-sync 37 minutes after boot stripped the entry on all 5 workers, and every pod started afterwards ran outside the mesh. Workload rolls could not fix it (a replacement pod just goes through plain flannel again) and #641's eviction self-heal is actively counterproductive there. Add a re-assert loop to the long-running agent: a controller-runtime runnable watching the CNI config dir with fsnotify (settle delay so a partial in-place write is never parsed) plus a 60s re-check for events fsnotify never delivers. When the aether entry is missing from the conflist kubelet actually uses, it is re-appended via the shared cni/conflist mutation and written atomically (tmp+rename). Guardrails — the loop only ever repairs, never creates: - the file must exist, parse as a conflist, and still carry a primary CNI plugin (aether chains ONTO someone else's network config; boot ordering stays cni-install's job), - the entry re-appended is the last one OBSERVED in the file, so the installer-time netconf parameters (OTLP endpoint, redirect-all default, mesh-DNS DNAT target) are never re-derived by the agent; cni-install re-renders them at every agent pod start, priming the cache on the first check of every agent lifetime, - a broken watch degrades to periodic re-checks and never fails the manager (which would take the CNI socket down with it). Observability: aether.agent.cni_conflist.reasserts counts every repair (each one is a window in which new pods were created unmeshed), and the aether.agent.cni_conflist.chained gauge is recorded on every check, zero included, so 0 is the alertable "pods on this node are bypassing the mesh" state — same recording philosophy as the #641 unmeshed_pods gauge. Gated by --cni-conflist-reassert, default ON (it is a safety net), with the matching agent.cniConflistReassert chart value. The agent container now mounts /etc/cni/net.d read-write; the cni-install init container already mounted it for the one-shot append. Fix shape (1) from #645 — a standalone 05-aether.conflist with no competing writer — remains open; this is shape (2) + (3). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
fsnotify closes both of its channels when the watcher dies (a lost inotify instance, a Close from under us). A closed channel is always ready, so the select would take the event branch forever on zero-valued events and burn a core. Drop the channels to nil on close — nil never fires — and fall back to the periodic re-check, which is what the loop already does when the watch could not be established in the first place. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Owner
Author
|
Follow-up commit |
This was referenced Aug 30, 2026
bpalermo
added a commit
that referenced
this pull request
Sep 5, 2026
…#710) `cni/internal/install` logged half the install through `ctrl.Log` — controller-runtime's global logger — but nothing in `cni/` ever calls `ctrl.SetLogger`, so controller-runtime discarded every one of those records. On talos-main the `cni-install` init container therefore ended at `CNI binaries installed`: the pre-existing `Wrote CNI config` confirmation (the #645/#650 class signal that aether was chained into the node's conflist) and #689's `Wrote the durable aether CNI entry`, plus both of its `Error` paths, were silent in production. Take the issue's preferred fix: drop `ctrl.Log` and thread the installer's own logger down. The installer now holds a `*slog.Logger` instead of a logr bridge — the cni-install command already built the slog logger and only bridged it for controller-runtime's sake — and `cniconfig.go` and `cni/internal/util`'s file watcher take it as a parameter. controller-runtime is gone from all three packages; `cni/cmd/cni-install/main.go` keeps `ctrl.SetupSignalHandler`, which does not log. Messages and attribute keys are unchanged so operator greps still match. The two `Info` calls whose key/value list was malformed (a dangling value, and a bare filepath) get their `filepath`/`alternate` keys so slog does not render `!BADKEY`; logr's error argument becomes the repo-standard `"error", err` pair. Tests capture the installer's logger through a slog JSON handler and assert `Wrote CNI config` and `Wrote the durable aether CNI entry` are emitted at INFO with their filepath, and that both durable-entry failure paths (unwritable location, no aether entry to extract) log at ERROR — that ERROR line is the operator's only signal, since the durable write is deliberately swallowed. Verified end to end by running the built binary against a scratch conflist: six lines now, including the two that were missing. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[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.
Fixes shapes (2) and (3) of #645.
Mechanism
cni-installappends aether's chained plugin entry to the primary CNI's conflist once, from the agent pod's init container. kube-flannel's init container does an unconditionalcp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.confliston every flannel pod recreation. aether appends once, flannel overwrites on every re-sync, so aether always loses eventually — and when it does, the plugin binary stays on disk but is unchained: no CNI ADD ever reaches the agent and every subsequently-started pod runs outside the mesh.This PR adds a re-assert loop to the long-running agent (
agent/internal/cniconflist), registered as a controller-runtime runnable alongside the other agent runnables:cp -fwalks the file through a truncated state that would parse as garbage, and the delay also collapses one rewrite's event burst into a single check. Events for temp files (atomic writers'.tmp-ish names) and chmod-only ops are filtered out.common/file.AtomicWrite, 0644).The mutation is not forked: the first commit extracts it from
cni/internal/install(which the agent cannot import — it isinternalto//cni) into the importableaethermesh.dev/cni/conflist, now used by both the installer and the agent. The installer keeps writing byte-for-byte what it wrote before; its moved tests moved with it.Incident reference
2026-08-29, third power-blip incident — but not the boot race (#640). Talos re-applied its bundled bootstrap manifests (
node-fetchfield manager) at 19:01:09Z, ~37 min after apiserver came up, rolling all 6 kube-flannel pods (restartCount 0, fresh pods). Each node's conflist mtime matched its new flannel pod's init container to the second;plugins=[flannel, portmap]on all 5 workers. Total mesh outage. Workload rolls were proven useless (39 pods rolled, SLI stayed at 100% failure) — recovery required rollingds/aether-agentto re-run cni-install. Talos re-syncs those manifests on boot, ontalosctl apply-config, and on Kubernetes upgrades, so this is not power-event-specific.Guardrails
The loop only ever repairs, never creates:
Startnever returns an error, because failing the manager would take the CNI socket down with it.NeedLeaderElection() == false— every node's conflist is that node's own.Gated by
--cni-conflist-reassert, default ON (safety net, same posture as the other default-on kill switches), with the matchingagent.cniConflistReassertchart value. The agent container now mounts/etc/cni/net.dread-write (the cni-install init container already mounted it for the one-shot append);charts/aether/Chart.yamlbumped 0.91.1 → 0.91.2.Metrics + the alert to come
aether.agent.cni_conflist.reasserts(counter) — every repair is a window in which new pods were created unmeshed. INFO log on each; WARN on any failed re-assert.aether.agent.cni_conflist.chained(gauge) — 1 when aether's entry is present in the active conflist, 0 when missing or when no usable conflist exists. Recorded on every check tick, zero included, so it clears the instant the entry is back — same recording philosophy as the fix(agent): self-heal pods left unmeshed by the reboot CNI boot race #641unmeshed_podsgauge.The gauge is the detection fix the incident asked for: nothing watched the conflist, and the failure surfaced only as downstream symptoms (prober SLI 100% failure, ghost-sweep "live mesh pod missing from local storage" warnings). A GitOps-side alert on
aether_agent_cni_conflist_chained == 0(with afor:window so a repaired blip doesn't page) is the follow-up, to be wired likeAetherUnmeshedPodsin bpalermo/k8s-talos-main — not in this repo.Test evidence
cni/conflist: the moved insert/parse/filename tests plus new coverage for the parse-side helpers, including a round-trip assertion that an entry recovered from a chained conflist re-inserts byte-identically to what cni-install writes.agent/internal/cniconflist: table-drivenchecktests — missing entry → re-appended; already chained → byte-identical no-op; invalid JSON → untouched; no primary CNI plugin → untouched; missing entry with no known-good entry → untouched; absent dir and empty dir → no-op and nothing created; only the active conflist is repaired while other configs in the dir are left alone; and priming (chained file observed → strip → restored to exactly the installer's bytes).TestStartConverges): a flannel-only conflist is written over the chained one mid-watch and the file converges back to chained, with the periodic re-check set to 1h so only the watcher can be what fixed it. PlusTestStartWithoutConflistDirfor the degraded path.bazel test //agent/... //cni/...green (30 + 9 targets); the new test passed--runs_per_test=20.bazel build //...green,bazel build --config=cigreen on the touched packages,--config=lintclean (gocognit included),make format-checkclean,helm templaterenders the flag and the read-write mount.Still open
Fix shape (1) of #645 — a standalone
05-aether.conflistwith no competing writer — remains open and is tracked there. It needs the aether conflist to become self-sufficient (delegate/chain to flannel from aether's own file), which is a design change; this PR is the pragmatic first step that closes the window to seconds and makes the condition alertable.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr