Skip to content

Commit

Permalink
fix controller-runtime logger not set (kubeovn#4380)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
  • Loading branch information
zhangzujian committed Aug 12, 2024
1 parent fa2316a commit 39980fb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"k8s.io/client-go/tools/leaderelection/resourcelock"
"k8s.io/client-go/tools/record"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

Expand All @@ -33,8 +34,6 @@ const ovnLeaderResource = "kube-ovn-controller"
func CmdMain() {
defer klog.Flush()

ctx := signals.SetupSignalHandler()

klog.Infof(versions.String())

config, err := controller.ParseFlags()
Expand All @@ -47,6 +46,8 @@ func CmdMain() {
}
utilruntime.Must(kubeovnv1.AddToScheme(scheme.Scheme))

ctrl.SetLogger(klog.NewKlogr())
ctx := signals.SetupSignalHandler()
go func() {
if config.EnablePprof {
mux := http.NewServeMux()
Expand Down
2 changes: 2 additions & 0 deletions cmd/daemon/cniserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

Expand Down Expand Up @@ -60,6 +61,7 @@ func CmdMain() {
util.LogFatalAndExit(err, "failed to do the OS initialization")
}

ctrl.SetLogger(klog.NewKlogr())
ctx := signals.SetupSignalHandler()
stopCh := ctx.Done()
podInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(config.KubeClient, 0,
Expand Down
2 changes: 2 additions & 0 deletions cmd/ovn_monitor/ovn_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

"github.com/kubeovn/kube-ovn/pkg/metrics"
Expand Down Expand Up @@ -38,6 +39,7 @@ func CmdMain() {
}
exporter.StartOvnMetrics()

ctrl.SetLogger(klog.NewKlogr())
ctx := signals.SetupSignalHandler()
if err = metrics.Run(ctx, nil, addr, config.SecureServing); err != nil {
util.LogFatalAndExit(err, "failed to run metrics server")
Expand Down
2 changes: 2 additions & 0 deletions cmd/pinger/pinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
_ "net/http/pprof" // #nosec

"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

"github.com/kubeovn/kube-ovn/pkg/metrics"
Expand All @@ -21,6 +22,7 @@ func CmdMain() {
util.LogFatalAndExit(err, "failed to parse config")
}

ctrl.SetLogger(klog.NewKlogr())
ctx := signals.SetupSignalHandler()
if config.Mode == "server" {
if config.EnableMetrics {
Expand Down

0 comments on commit 39980fb

Please sign in to comment.