diff --git a/cmd/handler/main.go b/cmd/handler/main.go index 88da51a764..75fc05de5d 100644 --- a/cmd/handler/main.go +++ b/cmd/handler/main.go @@ -24,7 +24,6 @@ import ( "os" "time" - "go.uber.org/zap/zapcore" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" @@ -91,7 +90,7 @@ func main() { flag.CommandLine.Set("zap-devel", "true") } - setupLogger(opt) + ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opt))) // Lock only for handler, we can run old and new version of // webhook without problems, policy status will be updated @@ -249,15 +248,6 @@ func main() { } } -func setupLogger(opts zap.Options) { - opts.EncoderConfigOptions = append(opts.EncoderConfigOptions, func(ec *zapcore.EncoderConfig) { - ec.EncodeTime = zapcore.ISO8601TimeEncoder - }) - - logger := zap.New(zap.UseFlagOptions(&opts)) - ctrl.SetLogger(logger) -} - // Start profiler on given port if ENABLE_PROFILER is True func setProfiler() { cfg := ProfilerConfig{} diff --git a/cmd/operator/main.go b/cmd/operator/main.go index 5dc872d6f2..95c4ddb815 100644 --- a/cmd/operator/main.go +++ b/cmd/operator/main.go @@ -24,7 +24,6 @@ import ( _ "net/http/pprof" "os" - "go.uber.org/zap/zapcore" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" @@ -76,7 +75,7 @@ func main() { flag.CommandLine.Set("zap-devel", "true") } - setupLogger(opt) + ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opt))) ctrlOptions := ctrl.Options{ Scheme: scheme, @@ -107,15 +106,6 @@ func main() { } } -func setupLogger(opts zap.Options) { - opts.EncoderConfigOptions = append(opts.EncoderConfigOptions, func(ec *zapcore.EncoderConfig) { - ec.EncodeTime = zapcore.ISO8601TimeEncoder - }) - - logger := zap.New(zap.UseFlagOptions(&opts)) - ctrl.SetLogger(logger) -} - // Start profiler on given port if ENABLE_PROFILER is True func setProfiler() { cfg := ProfilerConfig{} diff --git a/deploy/handler/operator.yaml b/deploy/handler/operator.yaml index 615b690754..3c3b52fba5 100644 --- a/deploy/handler/operator.yaml +++ b/deploy/handler/operator.yaml @@ -31,6 +31,8 @@ spec: priorityClassName: system-cluster-critical containers: - name: nmstate-webhook + args: + - --zap-time-encoding=iso8601 # Replace this with the built image name image: {{ .HandlerImage }} imagePullPolicy: {{ .HandlerPullPolicy }} @@ -113,6 +115,8 @@ spec: priorityClassName: system-cluster-critical containers: - name: nmstate-cert-manager + args: + - --zap-time-encoding=iso8601 # Replace this with the built image name image: {{ .HandlerImage }} imagePullPolicy: {{ .HandlerPullPolicy }} @@ -205,6 +209,8 @@ spec: priorityClassName: system-node-critical containers: - name: nmstate-handler + args: + - --zap-time-encoding=iso8601 # Replace this with the built image name image: {{ .HandlerImage }} imagePullPolicy: {{ .HandlerPullPolicy }} diff --git a/deploy/operator/operator.yaml b/deploy/operator/operator.yaml index 2bfe96fa1c..8d9b50c250 100644 --- a/deploy/operator/operator.yaml +++ b/deploy/operator/operator.yaml @@ -26,6 +26,8 @@ spec: effect: NoSchedule containers: - name: nmstate-operator + args: + - --zap-time-encoding=iso8601 # Replace this with the built image name image: {{ .OperatorImage }} imagePullPolicy: {{ .OperatorPullPolicy }}