From 27b8b7cf0af6e15f2619654b7f7c30f86643acc9 Mon Sep 17 00:00:00 2001 From: Hans Rakers Date: Wed, 19 Jun 2024 13:51:53 +0200 Subject: [PATCH] feat: Use contextual logging --- .../templates/csi-controller-deploy.yaml | 11 ++- .../cloudstack-csi/templates/csi-node-ds.yaml | 2 + charts/cloudstack-csi/values.yaml | 3 + cmd/cloudstack-csi-driver/main.go | 77 ++++++++------- deploy/k8s/controller-deployment.yaml | 3 +- deploy/k8s/node-daemonset.yaml | 3 +- go.mod | 19 +++- go.sum | 94 +++++++------------ pkg/cloud/metadata.go | 33 ++++--- pkg/cloud/vms.go | 8 +- pkg/cloud/volumes.go | 23 +++-- pkg/cloud/zones.go | 5 +- pkg/driver/controller.go | 84 +++++++++++------ pkg/driver/driver.go | 12 +-- pkg/driver/identity.go | 27 ++++-- pkg/driver/node.go | 61 +++++++----- pkg/driver/server.go | 32 ++++--- pkg/mount/mount.go | 13 +-- pkg/util/idlocker.go | 10 +- test/sanity/sanity_test.go | 11 ++- 20 files changed, 301 insertions(+), 230 deletions(-) diff --git a/charts/cloudstack-csi/templates/csi-controller-deploy.yaml b/charts/cloudstack-csi/templates/csi-controller-deploy.yaml index c525664..2b5510d 100644 --- a/charts/cloudstack-csi/templates/csi-controller-deploy.yaml +++ b/charts/cloudstack-csi/templates/csi-controller-deploy.yaml @@ -45,7 +45,8 @@ spec: args: - "--endpoint=$(CSI_ENDPOINT)" - "--cloudstackconfig=$(CLOUD_CONFIG)" - - "--debug" + - "--logging-format={{ .Values.logFormat }}" + - "--v={{ .Values.logVerbosityLevel }}" {{- if .Values.controller.csiDriverController.extraArgs }} {{- with .Values.controller.csiDriverController.extraArgs }} {{- tpl . $ | trim | nindent 12 }} @@ -77,7 +78,7 @@ spec: image: "{{ .Values.controller.provisioner.image.repository }}:{{ .Values.controller.provisioner.image.tag }}" imagePullPolicy: {{ .Values.controller.provisioner.image.pullPolicy }} args: - - "-v={{ .Values.logVerbosityLevel }}" + - "--v={{ .Values.logVerbosityLevel }}" - "--csi-address=$(ADDRESS)" - "--timeout={{ .Values.timeout }}" - "--feature-gates=Topology={{ .Values.controller.provisioner.topology }}" @@ -110,7 +111,7 @@ spec: image: "{{ .Values.controller.attacher.image.repository }}:{{ .Values.controller.attacher.image.tag }}" imagePullPolicy: {{ .Values.controller.attacher.image.pullPolicy }} args: - - "-v={{ .Values.logVerbosityLevel }}" + - "--v={{ .Values.logVerbosityLevel }}" - "--csi-address=$(ADDRESS)" - "--timeout={{ .Values.timeout }}" - "--default-fstype=ext4" @@ -140,7 +141,7 @@ spec: image: "{{ .Values.controller.resizer.image.repository }}:{{ .Values.controller.resizer.image.tag }}" imagePullPolicy: {{ .Values.controller.resizer.image.pullPolicy }} args: - - "-v={{ .Values.logVerbosityLevel }}" + - "--v={{ .Values.logVerbosityLevel }}" - "--csi-address=$(ADDRESS)" - "--timeout={{ .Values.timeout }}" {{- if $enableLeaderElection }} @@ -170,7 +171,7 @@ spec: image: "{{ .Values.livenessProbe.image.repository }}:{{ .Values.livenessProbe.image.tag }}" imagePullPolicy: {{ .Values.livenessProbe.image.pullPolicy }} args: - - "-v={{ .Values.logVerbosityLevel }}" + - "--v={{ .Values.logVerbosityLevel }}" - "--csi-address=$(ADDRESS)" {{- if .Values.livenessProbe.extraArgs }} {{- with .Values.livenessProbe.extraArgs }} diff --git a/charts/cloudstack-csi/templates/csi-node-ds.yaml b/charts/cloudstack-csi/templates/csi-node-ds.yaml index 70c2d84..6d2d464 100644 --- a/charts/cloudstack-csi/templates/csi-node-ds.yaml +++ b/charts/cloudstack-csi/templates/csi-node-ds.yaml @@ -33,7 +33,9 @@ spec: args: - "--endpoint=$(CSI_ENDPOINT)" - "--cloudstackconfig=$(CLOUD_CONFIG)" + - "--logging-format={{ .Values.logFormat }}" - "--nodeName=$(NODE_NAME)" + - "--v={{ .Values.logVerbosityLevel }}" {{- if .Values.node.csiDriver.extraArgs }} {{- with .Values.node.csiDriver.extraArgs }} {{- tpl . $ | trim | nindent 12 }} diff --git a/charts/cloudstack-csi/values.yaml b/charts/cloudstack-csi/values.yaml index d1dd7bc..40fb8bb 100644 --- a/charts/cloudstack-csi/values.yaml +++ b/charts/cloudstack-csi/values.yaml @@ -188,6 +188,9 @@ syncer: # for description of individual verbosity levels. logVerbosityLevel: 2 +# Log format. Available options are "text" and "json" +logFormat: text + # the secret should contain the cloudstack credentials # there are several options to inject the credentials: # 1) from kubernetes secret that doesn't exist: set "enabled" and "create" to true, this will create a secret from the values written to "data" down below diff --git a/cmd/cloudstack-csi-driver/main.go b/cmd/cloudstack-csi-driver/main.go index c74e5fb..660c4cc 100644 --- a/cmd/cloudstack-csi-driver/main.go +++ b/cmd/cloudstack-csi-driver/main.go @@ -6,13 +6,17 @@ package main import ( + "context" "flag" "fmt" "os" "path" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" + "k8s.io/component-base/featuregate" + "k8s.io/component-base/logs" + logsapi "k8s.io/component-base/logs/api/v1" + "k8s.io/component-base/logs/json" + "k8s.io/klog/v2" "github.com/leaseweb/cloudstack-csi-driver/pkg/cloud" "github.com/leaseweb/cloudstack-csi-driver/pkg/driver" @@ -22,65 +26,58 @@ var ( endpoint = flag.String("endpoint", "unix:///tmp/csi.sock", "CSI endpoint") cloudstackconfig = flag.String("cloudstackconfig", "./cloud-config", "CloudStack configuration file") nodeName = flag.String("nodeName", "", "Node name") - debug = flag.Bool("debug", false, "Enable debug logging") showVersion = flag.Bool("version", false, "Show version") // Version is set by the build process. - version = "" - isDevEnv = false + version = "" ) func main() { - flag.Parse() - - if *showVersion { - baseName := path.Base(os.Args[0]) - fmt.Println(baseName, version) //nolint:forbidigo - - return + if err := logsapi.RegisterLogFormat(logsapi.JSONLogFormat, json.Factory{}, logsapi.LoggingBetaOptions); err != nil { + klog.ErrorS(err, "failed to register JSON log format") } - if version == "" { - isDevEnv = true + fg := featuregate.NewFeatureGate() + err := logsapi.AddFeatureGates(fg) + if err != nil { + klog.ErrorS(err, "failed to add feature gates") } - run() - os.Exit(0) -} - -func run() { - // Setup logging. - var logConfig zap.Config - if isDevEnv { - logConfig = zap.NewDevelopmentConfig() - } else { - logConfig = zap.NewProductionConfig() + c := logsapi.NewLoggingConfiguration() + logsapi.AddGoFlags(c, flag.CommandLine) + flag.Parse() + logs.InitLogs() + logger := klog.Background() + if err = logsapi.ValidateAndApply(c, fg); err != nil { + logger.Error(err, "LoggingConfiguration is invalid") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) } - if *debug { - logConfig.Level.SetLevel(zapcore.DebugLevel) + + if *showVersion { + baseName := path.Base(os.Args[0]) + fmt.Println(baseName, version) //nolint:forbidigo + os.Exit(0) } - logger, _ := logConfig.Build() - defer func() { _ = logger.Sync() }() - undo := zap.ReplaceGlobals(logger) - defer undo() // Setup cloud connector. config, err := cloud.ReadConfig(*cloudstackconfig) if err != nil { - logger.Sugar().Errorw("Cannot read CloudStack configuration", "error", err) - os.Exit(1) //nolint:gocritic + logger.Error(err, "Cannot read CloudStack configuration") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) } - logger.Sugar().Debugf("Successfully read CloudStack configuration %v", *cloudstackconfig) + logger.Info("Successfully read CloudStack configuration", "cloudstackconfig", *cloudstackconfig) + + ctx := klog.NewContext(context.Background(), logger) csConnector := cloud.New(config) - d, err := driver.New(*endpoint, csConnector, nil, *nodeName, version, logger) + d, err := driver.New(*endpoint, csConnector, nil, *nodeName, version) if err != nil { - logger.Sugar().Errorw("Failed to initialize driver", "error", err) - os.Exit(1) + logger.Error(err, "Failed to initialize driver") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) } - if err = d.Run(); err != nil { - logger.Sugar().Errorw("Server error", "error", err) - os.Exit(1) + if err = d.Run(ctx); err != nil { + logger.Error(err, "Failed to run driver") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) } } diff --git a/deploy/k8s/controller-deployment.yaml b/deploy/k8s/controller-deployment.yaml index 2afab09..5b44958 100644 --- a/deploy/k8s/controller-deployment.yaml +++ b/deploy/k8s/controller-deployment.yaml @@ -38,7 +38,8 @@ spec: args: - "-endpoint=$(CSI_ENDPOINT)" - "-cloudstackconfig=/etc/cloudstack-csi-driver/cloud-config" - - "-debug" + - "-logging-format=text" + - "-v=4" env: - name: CSI_ENDPOINT value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock diff --git a/deploy/k8s/node-daemonset.yaml b/deploy/k8s/node-daemonset.yaml index f7cd3cd..e39ae10 100644 --- a/deploy/k8s/node-daemonset.yaml +++ b/deploy/k8s/node-daemonset.yaml @@ -30,8 +30,9 @@ spec: args: - "-endpoint=$(CSI_ENDPOINT)" - "-cloudstackconfig=/etc/cloudstack-csi-driver/cloud-config" + - "-logging-format=text" - "-nodeName=$(NODE_NAME)" - - "-debug" + - "-v=4" env: - name: CSI_ENDPOINT value: unix:///csi/csi.sock diff --git a/go.mod b/go.mod index 84b9eb0..8133e4f 100644 --- a/go.mod +++ b/go.mod @@ -5,25 +5,29 @@ go 1.21 require ( github.com/apache/cloudstack-go/v2 v2.16.1 github.com/container-storage-interface/spec v1.9.0 - github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 github.com/hashicorp/go-uuid v1.0.3 github.com/kubernetes-csi/csi-lib-utils v0.17.0 github.com/kubernetes-csi/csi-test/v5 v5.2.0 - go.uber.org/zap v1.27.0 golang.org/x/text v0.16.0 google.golang.org/grpc v1.64.0 gopkg.in/gcfg.v1 v1.2.3 k8s.io/api v0.29.6 k8s.io/apimachinery v0.29.6 k8s.io/client-go v0.29.6 + k8s.io/component-base v0.29.6 + k8s.io/klog/v2 v2.110.1 k8s.io/mount-utils v0.29.6 k8s.io/utils v0.0.0-20240102154912-e7106e64919e ) require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/blang/semver/v4 v4.0.0 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/go-logr/logr v1.3.0 // indirect + github.com/go-logr/zapr v1.2.3 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect @@ -37,17 +41,25 @@ require ( github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/google/uuid v1.6.0 // indirect github.com/imdario/mergo v0.3.6 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/moby/sys/mountinfo v0.6.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/onsi/ginkgo/v2 v2.13.1 // indirect github.com/onsi/gomega v1.30.0 // indirect + github.com/prometheus/client_golang v1.16.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.10.1 // indirect + github.com/spf13/cobra v1.7.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - go.uber.org/multierr v1.10.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sys v0.20.0 // indirect @@ -61,7 +73,6 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/klog/v2 v2.110.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect diff --git a/go.sum b/go.sum index 546e66a..606a42f 100644 --- a/go.sum +++ b/go.sum @@ -1,55 +1,48 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/apache/cloudstack-go/v2 v2.16.1 h1:2wOE4RKEjWPRZNO7ZNnZYmR3JJ+JJPQwhoc7W1fkiK4= github.com/apache/cloudstack-go/v2 v2.16.1/go.mod h1:cZsgFe+VmrgLBm7QjeHTJBXYe8E5+yGYkdfwGb+Pu9c= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/container-storage-interface/spec v1.9.0 h1:zKtX4STsq31Knz3gciCYCi1SXtO2HJDecIjDVboYavY= github.com/container-storage-interface/spec v1.9.0/go.mod h1:ZfDu+3ZRyeVqxZM0Ds19MVLkN2d1XJ5MAfi1L3VjlT0= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= +github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -61,20 +54,19 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJY github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= -github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -89,6 +81,8 @@ github.com/kubernetes-csi/csi-test/v5 v5.2.0 h1:Z+sdARWC6VrONrxB24clCLCmnqCnZF7d github.com/kubernetes-csi/csi-test/v5 v5.2.0/go.mod h1:o/c5w+NU3RUNE+DbVRhEUTmkQVBGk+tFOB2yPXT8teo= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -102,21 +96,28 @@ github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM= github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -132,32 +133,23 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= -go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= -go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -168,27 +160,22 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= @@ -206,10 +193,7 @@ golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -222,20 +206,10 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= @@ -260,14 +234,14 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.29.6 h1:eDxIl8+PeEpwbe2YyS5RXJ9vdn4hnKWMBf4WUJP9DQM= k8s.io/api v0.29.6/go.mod h1:ZuUPMhJV74DJXapldbg6upaHfiOjrBb+0ffUbBi1jaw= k8s.io/apimachinery v0.29.6 h1:CLjJ5b0hWW7531n/njRE3rnusw3rhVGCFftPfnG54CI= k8s.io/apimachinery v0.29.6/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y= k8s.io/client-go v0.29.6 h1:5E2ebuB/p0F0THuQatyvhDvPL2SIeqwTPrtnrwKob/8= k8s.io/client-go v0.29.6/go.mod h1:jHZcrQqDplyv20v7eu+iFM4gTpglZSZoMVcKrh8sRGg= +k8s.io/component-base v0.29.6 h1:XkVJI67FvBgNb/3kKqvaGKokxUrIR0RrksCPNI+JYCs= +k8s.io/component-base v0.29.6/go.mod h1:kIahZm8aw9lV8Vw17LF89REmeBrv5+QEl3v7HsrmITY= k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= diff --git a/pkg/cloud/metadata.go b/pkg/cloud/metadata.go index a4fe792..6483f2d 100644 --- a/pkg/cloud/metadata.go +++ b/pkg/cloud/metadata.go @@ -4,10 +4,11 @@ import ( "context" "encoding/json" "fmt" + "log/slog" "os" "strings" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" + "k8s.io/klog/v2" ) const ( @@ -16,35 +17,36 @@ const ( ) func (c *client) metadataInstanceID(ctx context.Context) string { - slog := ctxzap.Extract(ctx).Sugar() + logger := klog.FromContext(ctx) + logger.V(4).Info("Attempting to retrieve metadata from envvar NODE_ID") // Try a NODE_ID environment variable if envNodeID := os.Getenv("NODE_ID"); envNodeID != "" { - slog.Debugf("Found CloudStack VM ID from environment variable NODE_ID: %s", envNodeID) + logger.V(4).Info("Found CloudStack VM ID from envvar NODE_ID", "nodeID", envNodeID) return envNodeID } // Try cloud-init - slog.Debug("Try with cloud-init") + logger.V(4).Info("Environment variable NODE_ID not found, trying with cloud-init") if _, err := os.Stat(cloudInitInstanceFilePath); err == nil { - slog.Debugf("File %s exists", cloudInitInstanceFilePath) + logger.V(4).Info("File " + cloudInitInstanceFilePath + " exists") ciData, err := c.readCloudInit(ctx, cloudInitInstanceFilePath) if err != nil { - slog.Errorf("Cannot read cloud-init instance data: %v", err) + logger.Error(err, "Cannot read cloud-init instance data") } else if ciData.V1.InstanceID != "" { - slog.Debugf("Found CloudStack VM ID from cloud-init: %s", ciData.V1.InstanceID) + logger.V(4).Info("Found CloudStack VM ID from cloud-init", "nodeID", ciData.V1.InstanceID) return ciData.V1.InstanceID } slog.Error("cloud-init instance ID is not provided") } else if os.IsNotExist(err) { - slog.Debugf("File %s does not exist", cloudInitInstanceFilePath) + logger.V(4).Info("File " + cloudInitInstanceFilePath + " does not exist") } else { - slog.Errorf("Cannot read %s: %v", cloudInitInstanceFilePath, err) + logger.Error(err, "Cannot read file "+cloudInitInstanceFilePath) } - slog.Debug("CloudStack VM ID not found in meta-data.") + logger.V(4).Info("CloudStack VM ID not found in meta-data") return "" } @@ -60,26 +62,27 @@ type cloudInitV1 struct { } func (c *client) readCloudInit(ctx context.Context, instanceFilePath string) (*cloudInitInstanceData, error) { - slog := ctxzap.Extract(ctx).Sugar() + logger := klog.FromContext(ctx) b, err := os.ReadFile(instanceFilePath) if err != nil { - slog.Errorf("Cannot read %s", instanceFilePath) + logger.Error(err, "Cannot read file "+instanceFilePath) return nil, err } var data cloudInitInstanceData if err := json.Unmarshal(b, &data); err != nil { - slog.Errorf("Cannot parse JSON file %s", instanceFilePath) + logger.Error(err, "Cannot parse JSON file "+instanceFilePath) return nil, err } if strings.ToLower(data.V1.CloudName) != cloudStackCloudName { - slog.Errorf("Cloud-Init cloud name is %s, only %s is supported", data.V1.CloudName, cloudStackCloudName) + err := fmt.Errorf("cloud name from cloud-init is %s, only %s is supported", data.V1.CloudName, cloudStackCloudName) + logger.Error(err, "Unsupported cloud name detected") - return nil, fmt.Errorf("Cloud-Init cloud name is %s, only %s is supported", data.V1.CloudName, cloudStackCloudName) + return nil, err } return &data, nil diff --git a/pkg/cloud/vms.go b/pkg/cloud/vms.go index 5b41957..68a0505 100644 --- a/pkg/cloud/vms.go +++ b/pkg/cloud/vms.go @@ -3,13 +3,14 @@ package cloud import ( "context" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" + "k8s.io/klog/v2" ) func (c *client) GetVMByID(ctx context.Context, vmID string) (*VM, error) { + logger := klog.FromContext(ctx) p := c.VirtualMachine.NewListVirtualMachinesParams() p.SetId(vmID) - ctxzap.Extract(ctx).Sugar().Infow("CloudStack API call", "command", "ListVirtualMachines", "params", map[string]string{ + logger.V(2).Info("CloudStack API call", "command", "ListVirtualMachines", "params", map[string]string{ "id": vmID, }) l, err := c.VirtualMachine.ListVirtualMachines(p) @@ -31,9 +32,10 @@ func (c *client) GetVMByID(ctx context.Context, vmID string) (*VM, error) { } func (c *client) getVMByName(ctx context.Context, name string) (*VM, error) { + logger := klog.FromContext(ctx) p := c.VirtualMachine.NewListVirtualMachinesParams() p.SetName(name) - ctxzap.Extract(ctx).Sugar().Infow("CloudStack API call", "command", "ListVirtualMachines", "params", map[string]string{ + logger.V(2).Info("CloudStack API call", "command", "ListVirtualMachines", "params", map[string]string{ "name": name, }) l, err := c.VirtualMachine.ListVirtualMachines(p) diff --git a/pkg/cloud/volumes.go b/pkg/cloud/volumes.go index e4c4d72..f367796 100644 --- a/pkg/cloud/volumes.go +++ b/pkg/cloud/volumes.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/apache/cloudstack-go/v2/cloudstack" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" + "k8s.io/klog/v2" "github.com/leaseweb/cloudstack-csi-driver/pkg/util" ) @@ -38,9 +38,10 @@ func (c *client) listVolumes(p *cloudstack.ListVolumesParams) (*Volume, error) { } func (c *client) GetVolumeByID(ctx context.Context, volumeID string) (*Volume, error) { + logger := klog.FromContext(ctx) p := c.Volume.NewListVolumesParams() p.SetId(volumeID) - ctxzap.Extract(ctx).Sugar().Infow("CloudStack API call", "command", "ListVolumes", "params", map[string]string{ + logger.V(2).Info("CloudStack API call", "command", "ListVolumes", "params", map[string]string{ "id": volumeID, }) @@ -48,9 +49,10 @@ func (c *client) GetVolumeByID(ctx context.Context, volumeID string) (*Volume, e } func (c *client) GetVolumeByName(ctx context.Context, name string) (*Volume, error) { + logger := klog.FromContext(ctx) p := c.Volume.NewListVolumesParams() p.SetName(name) - ctxzap.Extract(ctx).Sugar().Infow("CloudStack API call", "command", "ListVolumes", "params", map[string]string{ + logger.V(2).Info("CloudStack API call", "command", "ListVolumes", "params", map[string]string{ "name": name, }) @@ -58,12 +60,13 @@ func (c *client) GetVolumeByName(ctx context.Context, name string) (*Volume, err } func (c *client) CreateVolume(ctx context.Context, diskOfferingID, zoneID, name string, sizeInGB int64) (string, error) { + logger := klog.FromContext(ctx) p := c.Volume.NewCreateVolumeParams() p.SetDiskofferingid(diskOfferingID) p.SetZoneid(zoneID) p.SetName(name) p.SetSize(sizeInGB) - ctxzap.Extract(ctx).Sugar().Infow("CloudStack API call", "command", "CreateVolume", "params", map[string]string{ + logger.V(2).Info("CloudStack API call", "command", "CreateVolume", "params", map[string]string{ "diskofferingid": diskOfferingID, "zoneid": zoneID, "name": name, @@ -78,8 +81,9 @@ func (c *client) CreateVolume(ctx context.Context, diskOfferingID, zoneID, name } func (c *client) DeleteVolume(ctx context.Context, id string) error { + logger := klog.FromContext(ctx) p := c.Volume.NewDeleteVolumeParams(id) - ctxzap.Extract(ctx).Sugar().Infow("CloudStack API call", "command", "DeleteVolume", "params", map[string]string{ + logger.V(2).Info("CloudStack API call", "command", "DeleteVolume", "params", map[string]string{ "id": id, }) _, err := c.Volume.DeleteVolume(p) @@ -92,8 +96,9 @@ func (c *client) DeleteVolume(ctx context.Context, id string) error { } func (c *client) AttachVolume(ctx context.Context, volumeID, vmID string) (string, error) { + logger := klog.FromContext(ctx) p := c.Volume.NewAttachVolumeParams(volumeID, vmID) - ctxzap.Extract(ctx).Sugar().Infow("CloudStack API call", "command", "AttachVolume", "params", map[string]string{ + logger.V(2).Info("CloudStack API call", "command", "AttachVolume", "params", map[string]string{ "id": volumeID, "virtualmachineid": vmID, }) @@ -106,9 +111,10 @@ func (c *client) AttachVolume(ctx context.Context, volumeID, vmID string) (strin } func (c *client) DetachVolume(ctx context.Context, volumeID string) error { + logger := klog.FromContext(ctx) p := c.Volume.NewDetachVolumeParams() p.SetId(volumeID) - ctxzap.Extract(ctx).Sugar().Infow("CloudStack API call", "command", "DetachVolume", "params", map[string]string{ + logger.V(2).Info("CloudStack API call", "command", "DetachVolume", "params", map[string]string{ "id": volumeID, }) _, err := c.Volume.DetachVolume(p) @@ -118,6 +124,7 @@ func (c *client) DetachVolume(ctx context.Context, volumeID string) error { // ExpandVolume expands the volume to new size. func (c *client) ExpandVolume(ctx context.Context, volumeID string, newSizeInGB int64) error { + logger := klog.FromContext(ctx) volume, _, err := c.Volume.GetVolumeByID(volumeID) if err != nil { return fmt.Errorf("failed to retrieve volume '%s': %w", volumeID, err) @@ -131,7 +138,7 @@ func (c *client) ExpandVolume(ctx context.Context, volumeID string, newSizeInGB p := c.Volume.NewResizeVolumeParams(volumeID) p.SetId(volumeID) p.SetSize(newSizeInGB) - ctxzap.Extract(ctx).Sugar().Infow("CloudStack API call", "command", "ExpandVolume", "params", map[string]string{ + logger.V(2).Info("CloudStack API call", "command", "ExpandVolume", "params", map[string]string{ "name": volumeName, "volumeid": volumeID, "current_size": strconv.FormatInt(currentSizeInGB, 10), diff --git a/pkg/cloud/zones.go b/pkg/cloud/zones.go index edb5f49..c137677 100644 --- a/pkg/cloud/zones.go +++ b/pkg/cloud/zones.go @@ -3,14 +3,15 @@ package cloud import ( "context" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" + "k8s.io/klog/v2" ) func (c *client) ListZonesID(ctx context.Context) ([]string, error) { + logger := klog.FromContext(ctx) result := make([]string, 0) p := c.Zone.NewListZonesParams() p.SetAvailable(true) - ctxzap.Extract(ctx).Sugar().Infow("CloudStack API call", "command", "ListZones", "params", map[string]string{ + logger.V(2).Info("CloudStack API call", "command", "ListZones", "params", map[string]string{ "available": "true", }) r, err := c.Zone.ListZones(p) diff --git a/pkg/driver/controller.go b/pkg/driver/controller.go index a4d1412..54b90a5 100644 --- a/pkg/driver/controller.go +++ b/pkg/driver/controller.go @@ -7,10 +7,10 @@ import ( "math/rand" "github.com/container-storage-interface/spec/lib/go/csi" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" "github.com/kubernetes-csi/csi-lib-utils/protosanitizer" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "k8s.io/klog/v2" "github.com/leaseweb/cloudstack-csi-driver/pkg/cloud" "github.com/leaseweb/cloudstack-csi-driver/pkg/util" @@ -39,6 +39,9 @@ func NewControllerServer(connector cloud.Interface) csi.ControllerServer { } func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("CreateVolume: called", "args", *req) + // Check arguments. if req.GetName() == "" { @@ -63,7 +66,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol } if acquired := cs.volumeLocks.TryAcquire(name); !acquired { - ctxzap.Extract(ctx).Sugar().Errorf(util.VolumeOperationAlreadyExistsFmt, name) + logger.Error(errors.New(util.ErrVolumeOperationAlreadyExistsVolumeName), "failed to acquire volume lock", "volumeName", name) return nil, status.Errorf(codes.Aborted, util.VolumeOperationAlreadyExistsFmt, name) } @@ -82,7 +85,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol return nil, status.Errorf(codes.AlreadyExists, "Volume %v already exists but does not satisfy request: %s", name, message) } // Existing volume is ok. - return &csi.CreateVolumeResponse{ + resp := &csi.CreateVolumeResponse{ Volume: &csi.Volume{ VolumeId: vol.ID, CapacityBytes: vol.Size, @@ -92,7 +95,9 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol Topology{ZoneID: vol.ZoneID}.ToCSI(), }, }, - }, nil + } + + return resp, nil } // We have to create the volume. @@ -129,7 +134,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol zoneID = t.ZoneID } - ctxzap.Extract(ctx).Sugar().Infow("Creating new volume", + logger.Info("Creating new volume", "name", name, "size", sizeInGB, "offering", diskOfferingID, @@ -141,7 +146,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol return nil, status.Errorf(codes.Internal, "Cannot create volume %s: %v", name, err.Error()) } - return &csi.CreateVolumeResponse{ + resp := &csi.CreateVolumeResponse{ Volume: &csi.Volume{ VolumeId: volID, CapacityBytes: util.GigaBytesToBytes(sizeInGB), @@ -151,7 +156,9 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol Topology{ZoneID: zoneID}.ToCSI(), }, }, - }, nil + } + + return resp, nil } func checkVolumeSuitable(vol *cloud.Volume, @@ -214,6 +221,9 @@ func determineSize(req *csi.CreateVolumeRequest) (int64, error) { } func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("DeleteVolume: called", "args", *req) + if req.GetVolumeId() == "" { return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request") } @@ -221,13 +231,13 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol volumeID := req.GetVolumeId() if acquired := cs.volumeLocks.TryAcquire(volumeID); !acquired { - ctxzap.Extract(ctx).Sugar().Errorf(util.VolumeOperationAlreadyExistsFmt, volumeID) + logger.Error(errors.New(util.ErrVolumeOperationAlreadyExistsVolumeID), "failed to acquire volume lock", "volumeID", volumeID) return nil, status.Errorf(codes.Aborted, util.VolumeOperationAlreadyExistsFmt, volumeID) } defer cs.volumeLocks.Release(volumeID) - ctxzap.Extract(ctx).Sugar().Infow("Deleting volume", + logger.Info("Deleting volume", "volumeID", volumeID, ) @@ -240,6 +250,9 @@ func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol } func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("ControllerPublishVolume: called", "args", *req) + // Check arguments. if req.GetVolumeId() == "" { @@ -263,7 +276,7 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs return nil, status.Error(codes.InvalidArgument, "Access mode not accepted") } - ctxzap.Extract(ctx).Sugar().Infow("Initiating attaching volume", + logger.Info("Initiating attaching volume", "volumeID", volumeID, "nodeID", nodeID, ) @@ -278,10 +291,10 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs } if vol.VirtualMachineID != "" && vol.VirtualMachineID != nodeID { - ctxzap.Extract(ctx).Sugar().Errorw("Volume already attached to another node", + logger.Error(nil, "Volume already attached to another node", "volumeID", volumeID, "nodeID", nodeID, - "attached nodeID", vol.VirtualMachineID, + "attachedNodeID", vol.VirtualMachineID, ) return nil, status.Error(codes.AlreadyExists, "Volume already assigned to another node") @@ -296,7 +309,7 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs if vol.VirtualMachineID == nodeID { // volume already attached. - ctxzap.Extract(ctx).Sugar().Infow("Volume already attached to node", + logger.Info("Volume already attached to node", "volumeID", volumeID, "nodeID", nodeID, "deviceID", vol.DeviceID, @@ -308,7 +321,7 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs return &csi.ControllerPublishVolumeResponse{PublishContext: publishContext}, nil } - ctxzap.Extract(ctx).Sugar().Infow("Attaching volume to node", + logger.Info("Attaching volume to node", "volumeID", volumeID, "nodeID", nodeID, ) @@ -318,7 +331,7 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs return nil, status.Errorf(codes.Internal, "Cannot attach volume %s: %s", volumeID, err.Error()) } - ctxzap.Extract(ctx).Sugar().Infow("Attached volume to node successfully", + logger.Info("Attached volume to node successfully", "volumeID", volumeID, "nodeID", nodeID, ) @@ -331,6 +344,9 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs } func (cs *controllerServer) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("ControllerUnpublishVolume: called", "args", *req) + // Check arguments. if req.GetVolumeId() == "" { @@ -355,7 +371,7 @@ func (cs *controllerServer) ControllerUnpublishVolume(ctx context.Context, req * // Check VM existence. if _, err := cs.connector.GetVMByID(ctx, nodeID); errors.Is(err, cloud.ErrNotFound) { // volumes cannot be attached to deleted VMs. - ctxzap.Extract(ctx).Sugar().Warnw("VM not found, marking ControllerUnpublishVolume successful", + logger.Error(nil, "VM not found, marking ControllerUnpublishVolume successful", "volumeID", volumeID, "nodeID", nodeID, ) @@ -366,7 +382,7 @@ func (cs *controllerServer) ControllerUnpublishVolume(ctx context.Context, req * return nil, status.Errorf(codes.Internal, "Error %v", err) } - ctxzap.Extract(ctx).Sugar().Infow("Detaching volume from node", + logger.Info("Detaching volume from node", "volumeID", volumeID, "nodeID", nodeID, ) @@ -376,7 +392,7 @@ func (cs *controllerServer) ControllerUnpublishVolume(ctx context.Context, req * return nil, status.Errorf(codes.Internal, "Cannot detach volume %s: %s", volumeID, err.Error()) } - ctxzap.Extract(ctx).Sugar().Infow("Detached volume from node successfully", + logger.Info("Detached volume from node successfully", "volumeID", volumeID, "nodeID", nodeID, ) @@ -385,6 +401,9 @@ func (cs *controllerServer) ControllerUnpublishVolume(ctx context.Context, req * } func (cs *controllerServer) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("ValidateVolumeCapabilities: called", "args", *req) + volumeID := req.GetVolumeId() if len(volumeID) == 0 { return nil, status.Error(codes.InvalidArgument, "Volume ID not provided") @@ -426,9 +445,10 @@ func isValidVolumeCapabilities(volCaps []*csi.VolumeCapability) bool { } func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("ControllerExpandVolume: called", "args", protosanitizer.StripSecrets(*req)) + expandVolumeLock := util.NewOperationLock(ctx) - logger := ctxzap.Extract(ctx).Sugar() - logger.Infow("Expand Volume: called with args", "args", protosanitizer.StripSecrets(*req)) volumeID := req.GetVolumeId() if len(volumeID) == 0 { @@ -436,7 +456,7 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi } err := expandVolumeLock.GetExpandLock(volumeID) if err != nil { - logger.Errorf(util.VolumeOperationAlreadyExistsFmt, volumeID) + logger.Error(err, "failed acquiring expand lock", "volumeID", volumeID) return nil, status.Errorf(codes.Aborted, util.VolumeOperationAlreadyExistsFmt, volumeID) } @@ -466,7 +486,10 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi if volume.Size >= util.GigaBytesToBytes(volSizeGB) { // A volume was already resized. - logger.Infof("Volume %q has been already expanded to %d. requested %d", volumeID, volume.Size, volSizeGB) + logger.Info("Volume has already been expanded", + "volumeID", volumeID, + "volumeSize", volume.Size, + "volumeSizeRequested", volSizeGB) return &csi.ControllerExpandVolumeResponse{ CapacityBytes: volume.Size, @@ -478,9 +501,9 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi return nil, status.Errorf(codes.Internal, "Could not resize volume %q to size %v: %v", volumeID, volSizeGB, err) } - logger.Infow("ControllerExpandVolume resized", - "requested_volume_ID", volumeID, - "new_size", volSizeGB, + logger.Info("Volume successfully expanded", + "volumeID", volumeID, + "volumeSize", volSizeGB, ) return &csi.ControllerExpandVolumeResponse{ @@ -489,8 +512,11 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi }, nil } -func (cs *controllerServer) ControllerGetCapabilities(_ context.Context, _ *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) { - return &csi.ControllerGetCapabilitiesResponse{ +func (cs *controllerServer) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("ControllerExpandVolume: called", "args", protosanitizer.StripSecrets(*req)) + + resp := &csi.ControllerGetCapabilitiesResponse{ Capabilities: []*csi.ControllerServiceCapability{ { Type: &csi.ControllerServiceCapability_Rpc{ @@ -514,5 +540,7 @@ func (cs *controllerServer) ControllerGetCapabilities(_ context.Context, _ *csi. }, }, }, - }, nil + } + + return resp, nil } diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go index 4f4945c..e5d8a14 100644 --- a/pkg/driver/driver.go +++ b/pkg/driver/driver.go @@ -4,7 +4,7 @@ package driver import ( - "go.uber.org/zap" + "context" "github.com/leaseweb/cloudstack-csi-driver/pkg/cloud" "github.com/leaseweb/cloudstack-csi-driver/pkg/mount" @@ -13,7 +13,7 @@ import ( // Interface is the CloudStack CSI driver interface. type Interface interface { // Run the CSI driver gRPC server - Run() error + Run(ctx context.Context) error } type cloudstackDriver struct { @@ -23,25 +23,23 @@ type cloudstackDriver struct { connector cloud.Interface mounter mount.Interface - logger *zap.Logger } // New instantiates a new CloudStack CSI driver. -func New(endpoint string, csConnector cloud.Interface, mounter mount.Interface, nodeName string, version string, logger *zap.Logger) (Interface, error) { +func New(endpoint string, csConnector cloud.Interface, mounter mount.Interface, nodeName string, version string) (Interface, error) { return &cloudstackDriver{ endpoint: endpoint, nodeName: nodeName, version: version, connector: csConnector, mounter: mounter, - logger: logger, }, nil } -func (cs *cloudstackDriver) Run() error { +func (cs *cloudstackDriver) Run(ctx context.Context) error { ids := NewIdentityServer(cs.version) ctrls := NewControllerServer(cs.connector) ns := NewNodeServer(cs.connector, cs.mounter, cs.nodeName) - return cs.serve(ids, ctrls, ns) + return cs.serve(ctx, ids, ctrls, ns) } diff --git a/pkg/driver/identity.go b/pkg/driver/identity.go index 52c2d7f..60ade9e 100644 --- a/pkg/driver/identity.go +++ b/pkg/driver/identity.go @@ -6,6 +6,7 @@ import ( "github.com/container-storage-interface/spec/lib/go/csi" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "k8s.io/klog/v2" ) type identityServer struct { @@ -20,23 +21,33 @@ func NewIdentityServer(version string) csi.IdentityServer { } } -func (ids *identityServer) GetPluginInfo(_ context.Context, _ *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) { +func (ids *identityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("GetPluginInfo: called", "args", *req) if ids.version == "" { return nil, status.Error(codes.Unavailable, "Driver is missing version") } - return &csi.GetPluginInfoResponse{ + resp := &csi.GetPluginInfoResponse{ Name: DriverName, VendorVersion: ids.version, - }, nil + } + + return resp, nil } -func (ids *identityServer) Probe(_ context.Context, _ *csi.ProbeRequest) (*csi.ProbeResponse, error) { +func (ids *identityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("Probe: called", "args", *req) + return &csi.ProbeResponse{}, nil } -func (ids *identityServer) GetPluginCapabilities(_ context.Context, _ *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { - return &csi.GetPluginCapabilitiesResponse{ +func (ids *identityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("Probe: called", "args", *req) + + resp := &csi.GetPluginCapabilitiesResponse{ Capabilities: []*csi.PluginCapability{ { Type: &csi.PluginCapability_Service_{ @@ -53,5 +64,7 @@ func (ids *identityServer) GetPluginCapabilities(_ context.Context, _ *csi.GetPl }, }, }, - }, nil + } + + return resp, nil } diff --git a/pkg/driver/node.go b/pkg/driver/node.go index 2110cd3..64f83de 100644 --- a/pkg/driver/node.go +++ b/pkg/driver/node.go @@ -8,9 +8,9 @@ import ( "path/filepath" "github.com/container-storage-interface/spec/lib/go/csi" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "k8s.io/klog/v2" "github.com/leaseweb/cloudstack-csi-driver/pkg/cloud" "github.com/leaseweb/cloudstack-csi-driver/pkg/mount" @@ -45,6 +45,9 @@ func NewNodeServer(connector cloud.Interface, mounter mount.Interface, nodeName } func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("NodeStageVolume: called", "args", *req) + // Check parameters volumeID := req.GetVolumeId() @@ -66,7 +69,7 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol } if acquired := ns.volumeLocks.TryAcquire(volumeID); !acquired { - ctxzap.Extract(ctx).Sugar().Errorf(util.VolumeOperationAlreadyExistsFmt, volumeID) + logger.Error(errors.New(util.ErrVolumeOperationAlreadyExistsVolumeID), "failed to acquire volume lock", "volumeID", volumeID) return nil, status.Errorf(codes.Aborted, util.VolumeOperationAlreadyExistsFmt, volumeID) } @@ -82,7 +85,7 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol return nil, status.Errorf(codes.Internal, "Cannot find device path for volume %s: %s", volumeID, err.Error()) } - ctxzap.Extract(ctx).Sugar().Infow("Device found", + logger.Info("Device found", "devicePath", devicePath, "deviceID", deviceID, ) @@ -120,7 +123,7 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol // Volume Mount if notMnt { - ctxzap.Extract(ctx).Sugar().Infow("NodeStageVolume: formatting and mounting", + logger.Info("NodeStageVolume: formatting and mounting", "devicePath", devicePath, "target", target, "fsType", fsType, @@ -149,6 +152,9 @@ func hasMountOption(options []string, opt string) bool { } func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("NodeUnstageVolume: called", "args", *req) + // Check parameters volumeID := req.GetVolumeId() @@ -162,7 +168,7 @@ func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag } if acquired := ns.volumeLocks.TryAcquire(volumeID); !acquired { - ctxzap.Extract(ctx).Sugar().Errorf(util.VolumeOperationAlreadyExistsFmt, volumeID) + logger.Error(errors.New(util.ErrVolumeOperationAlreadyExistsVolumeID), "failed to acquire volume lock", "volumeID", volumeID) return nil, status.Errorf(codes.Aborted, util.VolumeOperationAlreadyExistsFmt, volumeID) } @@ -180,7 +186,7 @@ func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag return &csi.NodeUnstageVolumeResponse{}, nil } - ctxzap.Extract(ctx).Sugar().Infow("NodeUnstageVolume: unmounting", + logger.Info("NodeUnstageVolume: unmounting", "target", target, ) @@ -189,7 +195,7 @@ func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag return nil, status.Errorf(codes.Internal, "failed to unmount target %q: %v", target, err) } - ctxzap.Extract(ctx).Sugar().Infow("NodeUnstageVolume: unmount successful", + logger.Info("NodeUnstageVolume: unmount successful", "target", target, ) @@ -197,6 +203,9 @@ func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag } func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) { //nolint:gocognit + logger := klog.FromContext(ctx) + logger.V(6).Info("NodePublishVolume: called", "args", *req) + // Check arguments if req.GetVolumeCapability() == nil { return nil, status.Error(codes.InvalidArgument, "Volume capability missing in request") @@ -247,7 +256,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis } } if !notMnt { - ctxzap.Extract(ctx).Sugar().Infow("NodePublishVolume: volume is already mounted", + logger.Info("NodePublishVolume: volume is already mounted", "source", source, "targetPath", targetPath, ) @@ -259,7 +268,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis mountFlags := req.GetVolumeCapability().GetMount().GetMountFlags() - ctxzap.Extract(ctx).Sugar().Infow("NodePublishVolume: mounting source", + logger.Info("NodePublishVolume: mounting source", "source", source, "targetPath", targetPath, "fsType", fsType, @@ -302,7 +311,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis return nil, status.Errorf(codes.Internal, "Could not create file %q: %v", targetPath, err) } - ctxzap.Extract(ctx).Sugar().Infow("NodePublishVolume: mounting device", + logger.Info("NodePublishVolume: mounting device", "devicePath", devicePath, "targetPath", targetPath, "deviceID", deviceID, @@ -319,6 +328,9 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis } func (ns *nodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("NodeUnpublishVolume: called", "args", *req) + volumeID := req.GetVolumeId() if volumeID == "" { return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request") @@ -338,7 +350,7 @@ func (ns *nodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu return nil, status.Errorf(codes.Internal, "Error %v", err) } - ctxzap.Extract(ctx).Sugar().Infow("NodeUnpublishVolume: unmounting volume", + logger.Info("NodeUnpublishVolume: unmounting volume", "targetPath", targetPath, "volumeID", volumeID, ) @@ -348,7 +360,7 @@ func (ns *nodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu return nil, status.Errorf(codes.Internal, "failed to unmount target %q: %v", targetPath, err) } - ctxzap.Extract(ctx).Sugar().Infow("NodeUnpublishVolume: unmounting successful", + logger.Info("NodeUnpublishVolume: unmounting successful", "targetPath", targetPath, "volumeID", volumeID, ) @@ -356,7 +368,10 @@ func (ns *nodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu return &csi.NodeUnpublishVolumeResponse{}, nil } -func (ns *nodeServer) NodeGetInfo(ctx context.Context, _ *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) { +func (ns *nodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("NodeGetInfo: called", "args", *req) + if ns.nodeName == "" { return nil, status.Error(codes.Internal, "Missing node name") } @@ -381,6 +396,9 @@ func (ns *nodeServer) NodeGetInfo(ctx context.Context, _ *csi.NodeGetInfoRequest } func (ns *nodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) { + logger := klog.FromContext(ctx) + logger.V(6).Info("NodeExpandVolume: called", "args", *req) + volumeID := req.GetVolumeId() if len(volumeID) == 0 { return nil, status.Error(codes.InvalidArgument, "Volume ID not provided") @@ -390,16 +408,11 @@ func (ns *nodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV return nil, status.Error(codes.InvalidArgument, "Volume path not provided") } - ctxzap.Extract(ctx).Sugar().Infow("Node expand volume called", - "volume_id", volumeID, - "volume_path", volumePath, - "method", "node_expand_volume", - ) volCap := req.GetVolumeCapability() if volCap != nil { switch volCap.GetAccessType().(type) { //nolint:gocritic case *csi.VolumeCapability_Block: - ctxzap.Extract(ctx).Sugar().Info("filesystem expansion is skipped for block volumes") + logger.Info("Filesystem expansion is skipped for block volumes") return &csi.NodeExpandVolumeResponse{}, nil } @@ -424,8 +437,10 @@ func (ns *nodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV return nil, status.Error(codes.Internal, fmt.Sprintf("Unable to find Device path for volume %s: %v", volumeID, err)) } - ctxzap.Extract(ctx).Sugar().Infow("Device found", + logger.Info("Expanding volume", "devicePath", devicePath, + "volumeID", volumeID, + "volumePath", volumePath, ) r := ns.mounter.NewResizeFs(mount.New()) @@ -437,7 +452,7 @@ func (ns *nodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV } func (ns *nodeServer) NodeGetCapabilities(_ context.Context, _ *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) { - return &csi.NodeGetCapabilitiesResponse{ + resp := &csi.NodeGetCapabilitiesResponse{ Capabilities: []*csi.NodeServiceCapability{ { Type: &csi.NodeServiceCapability_Rpc{ @@ -454,5 +469,7 @@ func (ns *nodeServer) NodeGetCapabilities(_ context.Context, _ *csi.NodeGetCapab }, }, }, - }, nil + } + + return resp, nil } diff --git a/pkg/driver/server.go b/pkg/driver/server.go index 1082b4f..a46ab10 100644 --- a/pkg/driver/server.go +++ b/pkg/driver/server.go @@ -8,11 +8,12 @@ import ( "strings" "github.com/container-storage-interface/spec/lib/go/csi" - grpc_zap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap" "google.golang.org/grpc" + "k8s.io/klog/v2" ) -func (cs *cloudstackDriver) serve(ids csi.IdentityServer, ctrls csi.ControllerServer, ns csi.NodeServer) error { +func (cs *cloudstackDriver) serve(ctx context.Context, ids csi.IdentityServer, ctrls csi.ControllerServer, ns csi.NodeServer) error { + logger := klog.FromContext(ctx) proto, addr, err := parseEndpoint(cs.endpoint) if err != nil { return err @@ -34,29 +35,30 @@ func (cs *cloudstackDriver) serve(ids csi.IdentityServer, ctrls csi.ControllerSe // Log every request and payloads (request + response) opts := []grpc.ServerOption{ - grpc.ChainUnaryInterceptor( - grpc_zap.UnaryServerInterceptor(cs.logger), - grpc_zap.PayloadUnaryServerInterceptor(cs.logger, func(context.Context, string, interface{}) bool { return true }), - ), - } - // Make sure that log statements internal to gRPC library are logged using the zapLogger as well. - grpc_zap.ReplaceGrpcLoggerV2(cs.logger) + grpc.UnaryInterceptor(func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + resp, err := handler(klog.NewContext(ctx, logger), req) + if err != nil { + logger.Error(err, "GRPC method failed", "method", info.FullMethod) + } - server := grpc.NewServer(opts...) + return resp, err + }), + } + grpcServer := grpc.NewServer(opts...) if ids != nil { - csi.RegisterIdentityServer(server, ids) + csi.RegisterIdentityServer(grpcServer, ids) } if ctrls != nil { - csi.RegisterControllerServer(server, ctrls) + csi.RegisterControllerServer(grpcServer, ctrls) } if ns != nil { - csi.RegisterNodeServer(server, ns) + csi.RegisterNodeServer(grpcServer, ns) } - cs.logger.Sugar().Infow("Listening for connections", "address", listener.Addr()) + logger.Info("Listening for connections", "address", listener.Addr()) - return server.Serve(listener) + return grpcServer.Serve(listener) } func parseEndpoint(ep string) (string, string, error) { diff --git a/pkg/mount/mount.go b/pkg/mount/mount.go index e7efa27..63aa90e 100644 --- a/pkg/mount/mount.go +++ b/pkg/mount/mount.go @@ -10,8 +10,8 @@ import ( "strings" "time" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/klog/v2" "k8s.io/mount-utils" "k8s.io/utils/exec" ) @@ -107,27 +107,28 @@ func (m *mounter) getDevicePathBySerialID(volumeID string) (string, error) { } func (m *mounter) probeVolume(ctx context.Context) { - log := ctxzap.Extract(ctx).Sugar() - log.Debug("Scanning SCSI host...") + logger := klog.FromContext(ctx) + logger.V(2).Info("Scanning SCSI host") scsiPath := "/sys/class/scsi_host/" if dirs, err := os.ReadDir(scsiPath); err == nil { for _, f := range dirs { name := scsiPath + f.Name() + "/scan" data := []byte("- - -") + logger.V(2).Info("Triggering SCSI host rescan") if err = os.WriteFile(name, data, 0o666); err != nil { //nolint:gosec - log.Warnf("Failed to rescan scsi host %s", name) + logger.Error(err, "Failed to rescan scsi host ", "dirName", name) } } } else { - log.Warnf("Failed to read %s, err %v", scsiPath, err) + logger.Error(err, "Failed to read dir ", "dirName", scsiPath) } args := []string{"trigger"} cmd := m.Exec.Command("udevadm", args...) _, err := cmd.CombinedOutput() if err != nil { - log.Warnf("Error running udevadm trigger %v\n", err) + logger.Error(err, "Error running udevadm trigger") } } diff --git a/pkg/util/idlocker.go b/pkg/util/idlocker.go index 675352f..f60fabf 100644 --- a/pkg/util/idlocker.go +++ b/pkg/util/idlocker.go @@ -18,11 +18,17 @@ import ( "fmt" "sync" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/klog/v2" ) const ( + // ErrVolumeOperationAlreadyExistsVolumeID is the error msg logged for concurrent operation. + ErrVolumeOperationAlreadyExistsVolumeID = "an operation with the given Volume ID already exists" + + // ErrVolumeOperationAlreadyExistsVolumeName is the error msg logged for concurrent operation. + ErrVolumeOperationAlreadyExistsVolumeName = "an operation with the given Volume name already exists" + // VolumeOperationAlreadyExistsFmt string format to return for concurrent operation. VolumeOperationAlreadyExistsFmt = "an operation with the given Volume ID %s already exists" @@ -245,6 +251,6 @@ func (ol *OperationLock) release(op operation, volumeID string) { } } default: - ctxzap.Extract(ol.ctx).Sugar().Errorf("%v operation not supported", op) + klog.Errorf("Lock release failed, operation %v not supported", op) } } diff --git a/test/sanity/sanity_test.go b/test/sanity/sanity_test.go index ce15105..27eede4 100644 --- a/test/sanity/sanity_test.go +++ b/test/sanity/sanity_test.go @@ -3,14 +3,14 @@ package sanity import ( + "context" "io/ioutil" + "k8s.io/klog/v2" "os" "path/filepath" "testing" "github.com/kubernetes-csi/csi-test/v5/pkg/sanity" - "go.uber.org/zap" - "github.com/leaseweb/cloudstack-csi-driver/pkg/cloud/fake" "github.com/leaseweb/cloudstack-csi-driver/pkg/driver" "github.com/leaseweb/cloudstack-csi-driver/pkg/mount" @@ -36,12 +36,15 @@ func TestSanity(t *testing.T) { driver.DiskOfferingKey: "9743fd77-0f5d-4ef9-b2f8-f194235c769c", } - csiDriver, err := driver.New(endpoint, fake.New(), mount.NewFake(), "node", "v0", zap.NewNop()) + logger := klog.Background() + ctx := klog.NewContext(context.Background(), logger) + + csiDriver, err := driver.New(endpoint, fake.New(), mount.NewFake(), "node", "v0") if err != nil { t.Fatalf("error creating driver: %v", err) } go func() { - csiDriver.Run() + csiDriver.Run(ctx) }() sanity.Test(t, config)