juicedata / juicefs-csi-driver

JuiceFS CSI Driver
https://github.com/juicedata/juicefs
Apache License 2.0
222 stars 85 forks source link

fix: Enable logging for the controller runtime #1186

Closed zwwhdls closed 3 days ago

zwwhdls commented 3 days ago

log error in dashboard:

I1113 11:39:50.440685       1 main.go:167] "listen and serve" logger="main" addr=":8088"
[controller-runtime] log.SetLogger(...) was never called; logs will not be displayed.
Detected at:
    >  goroutine 98 [running]:
    >  runtime/debug.Stack()
    >   /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
    >  sigs.k8s.io/controller-runtime/pkg/log.eventuallyFulfillRoot()
    >   /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.0/pkg/log/log.go:60 +0xcd
    >  sigs.k8s.io/controller-runtime/pkg/log.(*delegatingLogSink).WithValues(0xc000788000, {0xc0009bc4e0, 0x6, 0x6})
    >   /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.0/pkg/log/deleg.go:168 +0x49
    >  github.com/go-logr/logr.Logger.WithValues(...)
    >   /go/pkg/mod/github.com/go-logr/logr@v1.4.2/logr.go:332
    >  sigs.k8s.io/controller-runtime/pkg/controller.NewTypedUnmanaged[...].func1()
    >   /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.0/pkg/controller/controller.go:166 +0x205
    >  sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler(0x22ffcc0, {0x22e7868, 0xc000738640}, {{{0xc0009a2080, 0xb}, {0xc000526228, 0x17}}})
    >   /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.0/pkg/internal/controller/controller.go:293 +0x157
    >  sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem(0x22ffcc0, {0x22e7868, 0xc000738640})
    >   /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.0/pkg/internal/controller/controller.go:263 +0x21d
    >  sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2()
    >   /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.0/pkg/internal/controller/controller.go:224 +0x8a
    >  created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2 in goroutine 74
    >   /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.0/pkg/internal/controller/controller.go:220 +0x490

The controller runtime logger has not been set, which means we are missing information that could be useful in troubleshooting the controllers. Now the logger is enabled to give us this logging in the operator log. Enabled the log by default. See: https://github.com/rook/rook/issues/12434