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 }} diff --git a/go.mod b/go.mod index abbe2d1cf1..64bb6f0ee7 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,6 @@ require ( github.com/spf13/pflag v1.0.5 github.com/tidwall/gjson v1.9.3 github.com/tidwall/sjson v1.1.7 - go.uber.org/zap v1.19.1 gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.23.1 k8s.io/apimachinery v0.23.1 @@ -185,6 +184,7 @@ require ( go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect + go.uber.org/zap v1.19.1 // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect golang.org/x/mod v0.5.1 // indirect golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect