Skip to content

Commit f804e73

Browse files
committed
Set controller runtime logger on startup
Signed-off-by: Joe Nathan Abellard <[email protected]>
1 parent 571801f commit f804e73

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cmd/controller-manager/app/controllermanager.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ func NewControllerManagerCommand(ctx context.Context) *cobra.Command {
127127
return err
128128
}
129129
logs.InitLogs()
130+
131+
// Starting from version 0.15.0, controller-runtime expects its consumers to set a logger through log.SetLogger.
132+
// If SetLogger is not called within the first 30 seconds of a binaries lifetime, it will get
133+
// set to a NullLogSink and report an error. Here's to silence the "log.SetLogger(...) was never called; logs will not be displayed" error
134+
// by setting a logger through log.SetLogger.
135+
// More info refer to: https://github.com/karmada-io/karmada/pull/4885.
136+
controllerruntime.SetLogger(klog.Background())
130137
return nil
131138
},
132139

0 commit comments

Comments
 (0)