Repository navigation
fix(cni): make the installer's log lines actually reach stdout (#696) - #710
Merged
Merged
Conversation
`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. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Sep 5, 2026
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 #696.
The bug
cni/internal/installlogged part of the install throughinstallLog = ctrl.Log.WithName("installer")— controller-runtime's global logger — but nothing incni/ever callsctrl.SetLogger. controller-runtime discards writes to an unbound global logger, so every one of those records was dropped in production. On talos-main thecni-installinit container log ended atCNI binaries installed, and two things an operator needs were silent:Wrote CNI config— the confirmation that aether was chained into the node's conflist (the kube-flannel pod recreation clobbers the chained aether-cni conflist entry (Talos manifest re-sync) — silent fleet-wide unmeshing #645/fix(agent): re-assert the aether-cni conflist entry when a competing writer strips it (#645) #650 class signal). Silent since it was written.Wrote the durable aether CNI entry, plus both of itsErrorpaths — the only warning that the re-assert loop's priming file did not land.cni/internal/util's file watcher had the same unboundctrl.Log.The fix
The issue's preferred option: drop
ctrl.Logand thread the installer's own logger down.Installernow holds a*slog.Loggerrather than a logr bridge.cni/internal/cmdalready built the shared slog logger and only wrapped it inlogr.FromSlogHandlerbecause the install package used controller-runtime; that wrapper is gone.cniconfig.goandutil.CreateFileWatchertake the logger as a parameter.cni/internal/install,cni/internal/cmd, orcni/internal/util.cni/cmd/cni-install/main.gostill usesctrl.SetupSignalHandler, which does not log — nothing incni/touchesctrl.Logany more.Log messages and attribute keys are unchanged, so existing greps still match. Two secondary
Infocalls had malformed key/value lists (one dangling value, one bare filepath) that slog would render as!BADKEY; they get theirfilepath/alternatekeys. logr's leading error argument becomes the repo-standard"error", errpair.Validation
cni/internal/install/cniconfig_test.gocapture the installer's logger through a slog JSON handler and assertWrote CNI configandWrote the durable aether CNI entryare emitted at INFO with theirfilepath, and that both durable-entry failure paths log at ERROR — an unwritable location (a regular file standing in for the conf dir, so it fails as root too) and a conflist with no aether entry to extract. That ERROR line is the operator's only signal, since the durable write is deliberately swallowed so a lost safety net never fails an install that already meshed the node.bazel test //cni/...— 8/8 pass.bazel run //:gazelle,make format-checkclean.Related: #680, #689, #645, #650.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr