Skip to content

fix: Remove spurious "log.SetLogger(...) was never called" warning from controller-runtime#219

Merged
borchero merged 2 commits intomainfrom
claude/fix-spurious-log-message
Feb 25, 2026
Merged

fix: Remove spurious "log.SetLogger(...) was never called" warning from controller-runtime#219
borchero merged 2 commits intomainfrom
claude/fix-spurious-log-message

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Feb 25, 2026

controller-runtime logs a spurious warning when its logger is not initialized before background goroutines (e.g., reflectors) attempt to log. This appears intermittently in pod logs and may suppress subsequent log output.

Changes

  • Set controller-runtime logger using zapr.NewLogger() to bridge the existing zap logger with logr interface
  • Initialize logger immediately after zap setup, before manager creation
  • Add explicit dependency on github.com/go-logr/zapr
// Initialize logger
ctx := context.Background()
logger := zeus.Logger(ctx)
defer zeus.Sync()

// Set controller-runtime logger to prevent spurious log messages
ctrl.SetLogger(zapr.NewLogger(logger))
Original prompt

This section details on the original issue you should resolve

<issue_title>Spurious log message - "log.SetLogger(...) was never called"</issue_title>
<issue_description>Hello,

The attached log message pops up in the pod logs and, after that, I don't seem to get any further log output - this may well be a coincidence but, given the message content, I'm not sure!

Worth adding that it doesn't appear immediately - sometimes it pops up within minutes, sometimes a few days. I haven't worked out a pattern just yet. Let me know if I can provide any further info

[controller-runtime] log.SetLogger(...) was never called; logs will not be displayed.
Detected at:
        >  goroutine 93 [running]:
        >  runtime/debug.Stack()
        >       /usr/local/go/src/runtime/debug/stack.go:26 +0x5e
        >  sigs.k8s.io/controller-runtime/pkg/log.eventuallyFulfillRoot()
        >       /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.21.0/pkg/log/log.go:60 +0xcd
        >  sigs.k8s.io/controller-runtime/pkg/log.(*delegatingLogSink).Enabled(0xc000512680, 0x4)
        >       /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.21.0/pkg/log/deleg.go:111 +0x32
        >  github.com/go-logr/logr.Logger.Info({{0x221ccf8?, 0xc000512680?}, 0x1f1b94a?}, {0x1f05549, 0xb}, {0xc000680f00, 0x6, 0x6})
        >       /go/pkg/mod/github.com/go-logr/logr@v1.4.3/logr.go:276 +0x6e
        >  k8s.io/client-go/tools/cache.handleAnyWatch({0x2216b78, 0xc000569b30}, {0xc0007ac598?, 0x0?, 0x32835e0?}, {0x2201dc8, 0xc0000fe6e0}, {0x7fb89d3e65e8, 0xc0004e7cc0}, {0x2236860, ...}, ...)
        >       /go/pkg/mod/k8s.io/client-go@v0.33.2/tools/cache/reflector.go:946 +0x1365
        >  k8s.io/client-go/tools/cache.handleWatch({0x2216b78?, 0xc000569b30?}, {0xc0007ac598?, 0x0?, 0x32835e0?}, {0x2201dc8?, 0xc0000fe6e0?}, {0x7fb89d3e65e8?, 0xc0004e7cc0?}, {0x2236860, ...}, ...)
        >       /go/pkg/mod/k8s.io/client-go@v0.33.2/tools/cache/reflector.go:833 +0xea
        >  k8s.io/client-go/tools/cache.(*Reflector).watch(0xc0001b6b40, {0x2216b78, 0xc000569b30}, {0x0, 0x0}, 0xc0002253b0)
        >       /go/pkg/mod/k8s.io/client-go@v0.33.2/tools/cache/reflector.go:530 +0x61f
        >  k8s.io/client-go/tools/cache.(*Reflector).watchWithResync(0xc0001b6b40, {0x2216b78, 0xc000569b30}, {0x0, 0x0})
        >       /go/pkg/mod/k8s.io/client-go@v0.33.2/tools/cache/reflector.go:476 +0x186
        >  k8s.io/client-go/tools/cache.(*Reflector).ListAndWatchWithContext(0xc0001b6b40, {0x2216b78, 0xc000569b30})
        >       /go/pkg/mod/k8s.io/client-go@v0.33.2/tools/cache/reflector.go:431 +0x3b0
        >  k8s.io/client-go/tools/cache.(*Reflector).RunWithContext.func1()
        >       /go/pkg/mod/k8s.io/client-go@v0.33.2/tools/cache/reflector.go:359 +0x2e
        >  k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1({0x0?, 0x0?})
        >       /go/pkg/mod/k8s.io/apimachinery@v0.33.2/pkg/util/wait/backoff.go:233 +0x13
        >  k8s.io/apimachinery/pkg/util/wait.BackoffUntilWithContext.func1({0x2217958?, 0xc00042c9a0?}, 0x419074?)
        >       /go/pkg/mod/k8s.io/apimachinery@v0.33.2/pkg/util/wait/backoff.go:255 +0x51
        >  k8s.io/apimachinery/pkg/util/wait.BackoffUntilWithContext({0x2217958, 0xc00042c9a0}, 0xc000585ea8, {0x21f88a0, 0xc000601130}, 0x1)
        >       /go/pkg/mod/k8s.io/apimachinery@v0.33.2/pkg/util/wait/backoff.go:256 +0xe5
        >  k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0x221ccf8?, {0x21f88a0?, 0xc000601130?}, 0xb?, 0x12?)
        >       /go/pkg/mod/k8s.io/apimachinery@v0.33.2/pkg/util/wait/backoff.go:233 +0x46
        >  k8s.io/client-go/tools/cache.(*Reflector).RunWithContext(0xc0001b6b40, {0x2216b78, 0xc000569b30})
        >       /go/pkg/mod/k8s.io/client-go@v0.33.2/tools/cache/reflector.go:358 +0x22b
        >  k8s.io/client-go/tools/cache.(*controller).RunWithContext.(*Group).StartWithContext.func3()
        >       /go/pkg/mod/k8s.io/apimachinery@v0.33.2/pkg/util/wait/wait.go:63 +0x1f
        >  k8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1()
        >       /go/pkg/mod/k8s.io/apimachinery@v0.33.2/pkg/util/wait/wait.go:72 +0x4c
        >  created by k8s.io/apimachinery/pkg/util/wait.(*Group).Start in goroutine 87
        >       /go/pkg/mod/k8s.io/apimachinery@v0.33.2/pkg/util/wait/wait.go:70 +0x73
```</issue_description>

## Comments on the Issue (you are @claude[agent] in this section)

<comments>
</comments>

Co-authored-by: borchero <22455425+borchero@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Fix spurious log message regarding SetLogger call Fix spurious "log.SetLogger(...) was never called" warning from controller-runtime Feb 25, 2026
@Claude Claude AI requested a review from borchero February 25, 2026 14:11
@borchero borchero changed the title Fix spurious "log.SetLogger(...) was never called" warning from controller-runtime fix: Remove spurious "log.SetLogger(...) was never called" warning from controller-runtime Feb 25, 2026
@borchero borchero marked this pull request as ready for review February 25, 2026 14:18
@github-actions github-actions bot added the fix label Feb 25, 2026
@borchero borchero merged commit 00e957b into main Feb 25, 2026
8 of 11 checks passed
@borchero borchero deleted the claude/fix-spurious-log-message branch February 25, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spurious log message - "log.SetLogger(...) was never called"

2 participants