File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import (
21
21
22
22
"k8s.io/component-base/cli"
23
23
_ "k8s.io/component-base/logs/json/register" // for JSON log format registration
24
+ "k8s.io/klog/v2"
24
25
controllerruntime "sigs.k8s.io/controller-runtime"
25
26
_ "sigs.k8s.io/controller-runtime/pkg/metrics"
26
27
@@ -29,6 +30,12 @@ import (
29
30
30
31
func main () {
31
32
ctx := controllerruntime .SetupSignalHandler ()
33
+ // Starting from version 0.15.0, controller-runtime expects its consumers to set a logger through log.SetLogger.
34
+ // If SetLogger is not called within the first 30 seconds of a binaries lifetime, it will get
35
+ // set to a NullLogSink and report an error. Here's to silence the "log.SetLogger(...) was never called; logs will not be displayed" error
36
+ // by setting a logger through log.SetLogger.
37
+ // More info refer to: https://github.com/karmada-io/karmada/pull/4885.
38
+ controllerruntime .SetLogger (klog .Background ())
32
39
cmd := app .NewAgentCommand (ctx )
33
40
code := cli .Run (cmd )
34
41
os .Exit (code )
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import (
21
21
22
22
"k8s.io/component-base/cli"
23
23
_ "k8s.io/component-base/logs/json/register" // for JSON log format registration
24
+ "k8s.io/klog/v2"
24
25
controllerruntime "sigs.k8s.io/controller-runtime"
25
26
_ "sigs.k8s.io/controller-runtime/pkg/metrics"
26
27
@@ -29,6 +30,12 @@ import (
29
30
30
31
func main () {
31
32
ctx := controllerruntime .SetupSignalHandler ()
33
+ // Starting from version 0.15.0, controller-runtime expects its consumers to set a logger through log.SetLogger.
34
+ // If SetLogger is not called within the first 30 seconds of a binaries lifetime, it will get
35
+ // set to a NullLogSink and report an error. Here's to silence the "log.SetLogger(...) was never called; logs will not be displayed" error
36
+ // by setting a logger through log.SetLogger.
37
+ // More info refer to: https://github.com/karmada-io/karmada/pull/4885.
38
+ controllerruntime .SetLogger (klog .Background ())
32
39
command := app .NewOperatorCommand (ctx )
33
40
code := cli .Run (command )
34
41
os .Exit (code )
You can’t perform that action at this time.
0 commit comments