fix: reflect --namespaces-to-ignore in startup namespace-scope log#1163
Open
nikolauspschuetz wants to merge 1 commit into
Open
fix: reflect --namespaces-to-ignore in startup namespace-scope log#1163nikolauspschuetz wants to merge 1 commit into
nikolauspschuetz wants to merge 1 commit into
Conversation
When KUBERNETES_NAMESPACE is unset, startReloader logged "will detect changes in all namespaces." unconditionally, even when --namespaces-to-ignore was set, which is misleading. Extract the scope message into namespaceWatchScopeMessage(), move the log after ignoredNamespacesList is resolved, and include the excluded namespaces in the message when filtering is active. Closes stakater#1131 Assisted-by: Claude Code (Anthropic, Opus 4.x)
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.
Problem
When
KUBERNETES_NAMESPACEis unset (global mode), Reloader logs at startup:This message is printed unconditionally, even when
--namespaces-to-ignoreisconfigured, so the log claims it watches all namespaces while namespace
filtering is actually active. Reported in #1131 (confirmed on v1.4.2 and v1.4.14).
Root cause
internal/pkg/cmd/reloader.gologged the "all namespaces" message inside thelen(currentNamespace) == 0block (formerly line 118), beforeignoredNamespacesList := options.NamespacesToIgnorewas resolved (line 132).The log had no visibility into the ignore list.
Fix
namespaceWatchScopeMessage(ignoredNamespaces []string) string.ignoredNamespacesListis resolved (still gated onglobal mode).
--namespaces-to-ignoreis non-empty, the message now reads:KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces except: <ns1>, <ns2>.Otherwise the original message is unchanged.
Minimal diff: 17 insertions, 1 deletion in
reloader.goplus a new unit test.Test / verification
internal/pkg/cmd/reloader_test.go(TestNamespaceWatchScopeMessage)covering nil/empty (all-namespaces) and single/multiple ignored-namespace
cases. Verified it fails against the old behavior and passes with the
fix.
go test ./internal/pkg/cmd/...→ okgo vet ./internal/pkg/cmd/,go build ./...,gofmt -l→ cleanAI assistance
This change was prepared with AI assistance (Claude Code, Anthropic, Opus 4.x).
A human reviewed the root-cause analysis, the fix, and the test before opening
this PR. The commit carries an
Assisted-by:trailer.Closes #1131