Fix controller-runtime logger to suppress SetLogger warning - #461
Open
shashankvarma499 wants to merge 1 commit into
Open
shashankvarma499 wants to merge 1 commit into
shashankvarma499 wants to merge 1 commit into
Conversation
controller-runtime v0.22.0 emits a "log.SetLogger(...) was never called" warning with a full stack trace on every reconcile when its root logger is left unset. The provider only set the logger in debug mode, so the warning fired continuously in production. Set the logger unconditionally: use the zap logger in debug mode and a discard logger otherwise, preserving the existing quiet behaviour while satisfying controller-runtime's expectation. Fixes crossplane-contrib#342 Signed-off-by: Shashank Varma <324153016+shashankvarma499@users.noreply.github.com>
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.
Description of your changes
controller-runtime v0.22.0 emits a
log.SetLogger(...) was never calledwarning (with a full stack trace) on every reconcile when its root logger is
left unset. The provider only called
ctrl.SetLoggerin debug mode, so thiswarning fired continuously in production, polluting the logs with a stack trace
per reconcile.
Set the controller-runtime logger unconditionally: use the zap logger in debug
mode and a discard logger otherwise. This keeps the previous quiet behaviour in
non-debug mode while still satisfying controller-runtime's expectation and
eliminating the per-reconcile warning.
Fixes #342
I have:
make reviewableto ensure this PR is ready for review.How has this code been tested
go build ./...passes.go vet ./cmd/provider/...passes.go test ./... -count=1passes.cmd/provider/main.go(the entrypoint), which has nounit-test surface; behaviour is verified by running the provider and observing
the warning is gone.