From 6acc44c4e60f9a476655a393bc32cfb8f8f6c713 Mon Sep 17 00:00:00 2001 From: Praveen M Date: Wed, 18 Dec 2024 15:58:12 +0530 Subject: [PATCH 1/6] build: update Go 1.23 Signed-off-by: Praveen M --- api/go.mod | 2 +- build.env | 2 +- go.mod | 2 +- vendor/modules.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/go.mod b/api/go.mod index 9a79891ec26..f97d83970c6 100644 --- a/api/go.mod +++ b/api/go.mod @@ -1,6 +1,6 @@ module github.com/ceph/ceph-csi/api -go 1.22.5 +go 1.23.4 require ( github.com/ghodss/yaml v1.0.0 diff --git a/build.env b/build.env index a43841212bf..0f474fbe18b 100644 --- a/build.env +++ b/build.env @@ -19,7 +19,7 @@ BASE_IMAGE=quay.io/ceph/ceph:v19 CEPH_VERSION=squid # standard Golang options -GOLANG_VERSION=1.22.5 +GOLANG_VERSION=1.23.4 GO111MODULE=on # commitlint version diff --git a/go.mod b/go.mod index f5fab9614e6..3a8448f1fef 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ceph/ceph-csi -go 1.22.7 +go 1.23.4 require ( github.com/IBM/keyprotect-go-client v0.15.1 diff --git a/vendor/modules.txt b/vendor/modules.txt index bfb1aa3b9e3..b2de4e97b9b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -198,7 +198,7 @@ github.com/blang/semver/v4 ## explicit; go 1.18 github.com/cenkalti/backoff/v4 # github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000 => ./api -## explicit; go 1.22.5 +## explicit; go 1.23.4 github.com/ceph/ceph-csi/api/deploy/kubernetes github.com/ceph/ceph-csi/api/deploy/kubernetes/cephfs github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs From 7d0b8580ea0630b50407d1939129f980ddc78f47 Mon Sep 17 00:00:00 2001 From: Praveen M Date: Thu, 19 Dec 2024 14:53:38 +0530 Subject: [PATCH 2/6] ci: update golangci-lint to v1.62.2 - gomnd is replaced by mnd in v1.58.0 - gosec exlcude G115 rule (Potential integer overflow when converting between integer types) - disable new iface linter - disable new recvcheck linter Signed-off-by: Praveen M --- build.env | 2 +- e2e/rbd_helper.go | 8 ++++---- internal/cephfs/mounter/volumemounter.go | 2 +- internal/rbd/nodeserver.go | 2 +- internal/rbd/rbd_util.go | 2 +- scripts/golangci.yml.in | 8 ++++++++ 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/build.env b/build.env index 0f474fbe18b..3e2c59aa87e 100644 --- a/build.env +++ b/build.env @@ -26,7 +26,7 @@ GO111MODULE=on COMMITLINT_VERSION=latest # static checks and linters -GOLANGCI_VERSION=v1.57.2 +GOLANGCI_VERSION=v1.62.2 # external snapshotter version # Refer: https://github.com/kubernetes-csi/external-snapshotter/releases diff --git a/e2e/rbd_helper.go b/e2e/rbd_helper.go index 786660722df..7a00871e896 100644 --- a/e2e/rbd_helper.go +++ b/e2e/rbd_helper.go @@ -36,7 +36,7 @@ import ( "k8s.io/kubernetes/test/e2e/framework" ) -//nolint:gomnd // numbers specify Kernel versions. +//nolint:mnd // numbers specify Kernel versions. var nbdResizeSupport = []util.KernelVersion{ { Version: 5, @@ -48,7 +48,7 @@ var nbdResizeSupport = []util.KernelVersion{ }, // standard 5.3+ versions } -//nolint:gomnd // numbers specify Kernel versions. +//nolint:mnd // numbers specify Kernel versions. var fastDiffSupport = []util.KernelVersion{ { Version: 5, @@ -60,7 +60,7 @@ var fastDiffSupport = []util.KernelVersion{ }, // standard 5.3+ versions } -//nolint:gomnd // numbers specify Kernel versions. +//nolint:mnd // numbers specify Kernel versions. var deepFlattenSupport = []util.KernelVersion{ { Version: 5, @@ -75,7 +75,7 @@ var deepFlattenSupport = []util.KernelVersion{ // To use `io-timeout=0` we need // www.mail-archive.com/linux-block@vger.kernel.org/msg38060.html // -//nolint:gomnd // numbers specify Kernel versions. +//nolint:mnd // numbers specify Kernel versions. var nbdZeroIOtimeoutSupport = []util.KernelVersion{ { Version: 5, diff --git a/internal/cephfs/mounter/volumemounter.go b/internal/cephfs/mounter/volumemounter.go index 986ac6ee6b0..edf85f5d0df 100644 --- a/internal/cephfs/mounter/volumemounter.go +++ b/internal/cephfs/mounter/volumemounter.go @@ -31,7 +31,7 @@ import ( var ( availableMounters []string - //nolint:gomnd // numbers specify Kernel versions. + //nolint:mnd // numbers specify Kernel versions. quotaSupport = []util.KernelVersion{ { Version: 4, diff --git a/internal/rbd/nodeserver.go b/internal/rbd/nodeserver.go index 905fcf8affe..5702ad050f1 100644 --- a/internal/rbd/nodeserver.go +++ b/internal/rbd/nodeserver.go @@ -76,7 +76,7 @@ var ( kernelRelease = "" // deepFlattenSupport holds the list of kernel which support mapping rbd // image with deep-flatten image feature - //nolint:gomnd // numbers specify Kernel versions. + //nolint:mnd // numbers specify Kernel versions. deepFlattenSupport = []util.KernelVersion{ { Version: 5, diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index d1fc4a32801..274981bfe86 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -1793,7 +1793,7 @@ func (ri *rbdImageMetadataStash) String() string { func stashRBDImageMetadata(volOptions *rbdVolume, metaDataPath string) error { imgMeta := rbdImageMetadataStash{ // there are no checks for this at present - Version: 3, //nolint:gomnd // number specifies version. + Version: 3, //nolint:mnd // number specifies version. Pool: volOptions.Pool, RadosNamespace: volOptions.RadosNamespace, ImageName: volOptions.RbdImageName, diff --git a/scripts/golangci.yml.in b/scripts/golangci.yml.in index d96739ed396..fbdfd22670c 100644 --- a/scripts/golangci.yml.in +++ b/scripts/golangci.yml.in @@ -128,6 +128,10 @@ linters-settings: - dupImport # https://github.com/go-critic/go-critic/issues/845 # TODO: uncheckedInlineErr gives many false-positives - uncheckedInlineErr + gosec: + excludes: + # TODO: G115 gives many false-positives + - G115 # Potential integer overflow when converting between integer types unused: # treat code as a program (not a library) and report unused exported # identifiers; default is false. @@ -197,6 +201,7 @@ linters: - wrapcheck # TODO: enable linters added in golangci-lint 1.43 - contextcheck + - mnd - gomnd - ireturn - tagliatelle @@ -208,3 +213,6 @@ linters: - containedctx # TODO: depguard requires a list of (un)acceptable imports - depguard + # TODO enable linters added in golangci-lint 1.60 + - iface + - recvcheck From 31d1159858b58a443bfb0f591d4c960d74bd396b Mon Sep 17 00:00:00 2001 From: Praveen M Date: Fri, 20 Dec 2024 10:19:28 +0530 Subject: [PATCH 3/6] ci: address arguments have the wrong order (staticcheck) Signed-off-by: Praveen M --- internal/rbd/snapshot.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/rbd/snapshot.go b/internal/rbd/snapshot.go index 8fd0bfa128d..ff8887590c7 100644 --- a/internal/rbd/snapshot.go +++ b/internal/rbd/snapshot.go @@ -298,7 +298,7 @@ func (rv *rbdVolume) NewSnapshotByID( log.DebugLog(ctx, "going to clone snapshot image %q from image %q with snapshot ID %d", snap, rv, id) err = librbd.CloneImageByID(rv.ioctx, rv.RbdImageName, id, rv.ioctx, snap.RbdImageName, options) - if err != nil && !errors.Is(librbd.ErrExist, err) { + if err != nil && !errors.Is(err, librbd.ErrExist) { log.ErrorLog(ctx, "failed to clone snapshot %q with id %d: %v", snap, id, err) return nil, fmt.Errorf("failed to clone %q with snapshot id %d as new image %q: %w", rv.RbdImageName, id, snap, err) @@ -342,7 +342,7 @@ func (rv *rbdVolume) NewSnapshotByID( defer image.Close() snapImage, err = image.CreateSnapshot(snap.RbdSnapName) - if err != nil && !errors.Is(librbd.ErrExist, err) { + if err != nil && !errors.Is(err, librbd.ErrExist) { return nil, fmt.Errorf("failed to create snapshot on image %q: %w", snap, err) } From 6ccc77d5104bd9e4061be649f51e8880dda9ee56 Mon Sep 17 00:00:00 2001 From: Praveen M Date: Fri, 20 Dec 2024 11:14:51 +0530 Subject: [PATCH 4/6] ci: address shadowing of predeclared identifier Signed-off-by: Praveen M --- e2e/utils.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/utils.go b/e2e/utils.go index d0319aa2f63..6ad7ec526d7 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -1580,10 +1580,10 @@ func k8sVersionGreaterEquals(c kubernetes.Interface, major, minor int) bool { // return value. } - maj := strconv.Itoa(major) - min := strconv.Itoa(minor) + _maj := strconv.Itoa(major) + _min := strconv.Itoa(minor) - return (v.Major > maj) || (v.Major == maj && v.Minor >= min) + return (v.Major > _maj) || (v.Major == _maj && v.Minor >= _min) } // waitForJobCompletion polls the status of the given job and waits until the From 2526e583c0f6e744a80f5a28914ebf94e97b3584 Mon Sep 17 00:00:00 2001 From: Praveen M Date: Fri, 20 Dec 2024 11:15:55 +0530 Subject: [PATCH 5/6] ci: address return value is not checked (errcheck) Signed-off-by: Praveen M --- internal/kms/vault.go | 2 +- internal/kms/vault_tokens_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/kms/vault.go b/internal/kms/vault.go index 66da402ccbd..efc34fa5b8c 100644 --- a/internal/kms/vault.go +++ b/internal/kms/vault.go @@ -305,7 +305,7 @@ func (vc *vaultConnection) Destroy() { tmpFile, ok := vc.vaultConfig[api.EnvVaultCACert] if ok { // ignore error on failure to remove tmpfile (gosec complains) - //nolint:forcetypeassert // ignore error on failure to remove tmpfile + //nolint:forcetypeassert,errcheck // ignore error on failure to remove tmpfile _ = os.Remove(tmpFile.(string)) } } diff --git a/internal/kms/vault_tokens_test.go b/internal/kms/vault_tokens_test.go index b14f1c24956..e21c35a20e7 100644 --- a/internal/kms/vault_tokens_test.go +++ b/internal/kms/vault_tokens_test.go @@ -119,7 +119,7 @@ func TestInitVaultTokensKMS(t *testing.T) { // add tenant "bob" bob := make(map[string]interface{}) bob["vaultAddress"] = "https://vault.bob.example.org" - //nolint:forcetypeassert // as its a test we dont need to check assertion here. + //nolint:forcetypeassert,errcheck // as its a test we dont need to check assertion here. args.Config["tenants"].(map[string]interface{})["bob"] = bob _, err = initVaultTokensKMS(args) From c1ee4a5a0689aaf8f787387a5d04427caceed43c Mon Sep 17 00:00:00 2001 From: Praveen M Date: Fri, 20 Dec 2024 18:23:59 +0530 Subject: [PATCH 6/6] ci: non-constant format string (govet) Signed-off-by: Praveen M --- e2e/cephfs.go | 12 ++++++------ e2e/nfs.go | 2 +- e2e/rbd.go | 10 +++++----- e2e/rbd_helper.go | 2 +- internal/cephfs/driver.go | 8 ++++---- internal/cephfs/nodeserver.go | 4 ++-- .../persistentvolume/persistentvolume.go | 2 +- internal/csi-addons/rbd/encryptionkeyrotation.go | 4 ++-- internal/csi-addons/rbd/replication.go | 10 +++++----- internal/liveness/liveness.go | 2 +- internal/rbd/controllerserver.go | 16 ++++++++-------- internal/rbd/driver/driver.go | 10 +++++----- internal/util/topology_test.go | 2 +- 13 files changed, 42 insertions(+), 42 deletions(-) diff --git a/e2e/cephfs.go b/e2e/cephfs.go index d36873cfeb8..d100fbf894e 100644 --- a/e2e/cephfs.go +++ b/e2e/cephfs.go @@ -768,7 +768,7 @@ var _ = Describe(cephfsType, func() { for i := range deplPods { err = ensureStatSucceeds(deplPods[i].Name) if err != nil { - framework.Failf(err.Error()) + framework.Failf("%v", err.Error()) } } // Kill ceph-fuse in cephfs-csi node plugin Pods. @@ -797,12 +797,12 @@ var _ = Describe(cephfsType, func() { // the pod with hopefully mounts working again. err = deletePod(pod2Name, depl.Namespace, c, deployTimeout) if err != nil { - framework.Failf(err.Error()) + framework.Failf("%v", err.Error()) } // Wait for the second Pod to be recreated. err = waitForDeploymentComplete(c, depl.Name, depl.Namespace, deployTimeout) if err != nil { - framework.Failf(err.Error()) + framework.Failf("%v", err.Error()) } // List Deployment's pods again to get name of the new pod. deplPods, err = listPods(f, depl.Namespace, &metav1.ListOptions{ @@ -828,7 +828,7 @@ var _ = Describe(cephfsType, func() { // Verify Pod pod2Name has its ceph-fuse mount working again. err = ensureStatSucceeds(pod2Name) if err != nil { - framework.Failf(err.Error()) + framework.Failf("%v", err.Error()) } // Delete created resources. @@ -1083,7 +1083,7 @@ var _ = Describe(cephfsType, func() { &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("%v", stdErr) } // delete PVC and app @@ -2413,7 +2413,7 @@ var _ = Describe(cephfsType, func() { &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("%v", stdErr) } // delete cloned ROX pvc and app diff --git a/e2e/nfs.go b/e2e/nfs.go index a85004b50a4..c24dea1743b 100644 --- a/e2e/nfs.go +++ b/e2e/nfs.go @@ -614,7 +614,7 @@ var _ = Describe("nfs", func() { &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("%v", stdErr) } // delete PVC and app diff --git a/e2e/rbd.go b/e2e/rbd.go index 55bfab877f5..9a549033f40 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -1665,7 +1665,7 @@ var _ = Describe("RBD", func() { } readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("%v", stdErr) } } @@ -1798,7 +1798,7 @@ var _ = Describe("RBD", func() { } readOnlyErr := fmt.Sprintf("'%s': Operation not permitted", devPath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("%v", stdErr) } } err = deletePVCAndDeploymentApp(f, pvcClone, appClone) @@ -3357,7 +3357,7 @@ var _ = Describe("RBD", func() { &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("%v", stdErr) } } @@ -3471,7 +3471,7 @@ var _ = Describe("RBD", func() { &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("%v", stdErr) } } @@ -4133,7 +4133,7 @@ var _ = Describe("RBD", func() { &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("%v", stdErr) } // delete PVC and app diff --git a/e2e/rbd_helper.go b/e2e/rbd_helper.go index 7a00871e896..c2ef08b67d4 100644 --- a/e2e/rbd_helper.go +++ b/e2e/rbd_helper.go @@ -1071,7 +1071,7 @@ func waitToRemoveImagesFromTrash(f *framework.Framework, poolName string, t int) return true, nil } errReason = fmt.Errorf("found %d images found in trash. Image details %v", len(imagesInTrash), imagesInTrash) - framework.Logf(errReason.Error()) + framework.Logf("%v", errReason.Error()) return false, nil }) diff --git a/internal/cephfs/driver.go b/internal/cephfs/driver.go index 8023bb1a798..d6b38f3f147 100644 --- a/internal/cephfs/driver.go +++ b/internal/cephfs/driver.go @@ -109,7 +109,7 @@ func (fs *Driver) Run(conf *util.Config) { if conf.IsNodeServer && k8s.RunsOnKubernetes() { nodeLabels, err = k8s.GetNodeLabels(conf.NodeID) if err != nil { - log.FatalLogMsg(err.Error()) + log.FatalLogMsg("%v", err.Error()) } } @@ -159,7 +159,7 @@ func (fs *Driver) Run(conf *util.Config) { if conf.IsNodeServer { topology, err = util.GetTopologyFromDomainLabels(conf.DomainLabels, conf.NodeID, conf.DriverName) if err != nil { - log.FatalLogMsg(err.Error()) + log.FatalLogMsg("%v", err.Error()) } fs.ns = NewNodeServer( fs.cd, conf.Vtype, @@ -176,7 +176,7 @@ func (fs *Driver) Run(conf *util.Config) { if !conf.IsControllerServer && !conf.IsNodeServer { topology, err = util.GetTopologyFromDomainLabels(conf.DomainLabels, conf.NodeID, conf.DriverName) if err != nil { - log.FatalLogMsg(err.Error()) + log.FatalLogMsg("%v", err.Error()) } fs.ns = NewNodeServer( fs.cd, conf.Vtype, @@ -189,7 +189,7 @@ func (fs *Driver) Run(conf *util.Config) { // configure CSI-Addons server and components err = fs.setupCSIAddonsServer(conf) if err != nil { - log.FatalLogMsg(err.Error()) + log.FatalLogMsg("%v", err.Error()) } server := csicommon.NewNonBlockingGRPCServer() diff --git a/internal/cephfs/nodeserver.go b/internal/cephfs/nodeserver.go index b3a02ea321c..2a525e26d85 100644 --- a/internal/cephfs/nodeserver.go +++ b/internal/cephfs/nodeserver.go @@ -436,7 +436,7 @@ func getBackingSnapshotRoot( if err != nil { log.ErrorLog(ctx, "failed to open %s when searching for snapshot root: %v", snapshotsBase, err) - return "", status.Errorf(codes.Internal, err.Error()) + return "", status.Error(codes.Internal, err.Error()) } defer dir.Close() @@ -446,7 +446,7 @@ func getBackingSnapshotRoot( if err != nil { log.ErrorLog(ctx, "failed to read %s when searching for snapshot root: %v", snapshotsBase, err) - return "", status.Errorf(codes.Internal, err.Error()) + return "", status.Error(codes.Internal, err.Error()) } var ( diff --git a/internal/controller/persistentvolume/persistentvolume.go b/internal/controller/persistentvolume/persistentvolume.go index 07ff02d8f11..58e8db5969b 100644 --- a/internal/controller/persistentvolume/persistentvolume.go +++ b/internal/controller/persistentvolume/persistentvolume.go @@ -103,7 +103,7 @@ func (r *ReconcilePersistentVolume) getCredentials( if name == "" || namespace == "" { errStr := "secret name or secret namespace is empty" - log.ErrorLogMsg(errStr) + log.ErrorLogMsg("%v", errStr) return nil, errors.New(errStr) } diff --git a/internal/csi-addons/rbd/encryptionkeyrotation.go b/internal/csi-addons/rbd/encryptionkeyrotation.go index 8af1fa0ea38..b45ce4468b7 100644 --- a/internal/csi-addons/rbd/encryptionkeyrotation.go +++ b/internal/csi-addons/rbd/encryptionkeyrotation.go @@ -73,9 +73,9 @@ func (ekrs *EncryptionKeyRotationServer) EncryptionKeyRotate( err = status.Errorf(codes.NotFound, "volume ID %s not found", volID) case errors.Is(err, util.ErrPoolNotFound): log.ErrorLog(ctx, "failed to get backend volume for %s: %v", volID, err) - err = status.Errorf(codes.NotFound, err.Error()) + err = status.Error(codes.NotFound, err.Error()) default: - err = status.Errorf(codes.Internal, err.Error()) + err = status.Error(codes.Internal, err.Error()) } return nil, err diff --git a/internal/csi-addons/rbd/replication.go b/internal/csi-addons/rbd/replication.go index f87a2440161..566b59cf731 100644 --- a/internal/csi-addons/rbd/replication.go +++ b/internal/csi-addons/rbd/replication.go @@ -123,7 +123,7 @@ func getForceOption(ctx context.Context, parameters map[string]string) (bool, er } force, err := strconv.ParseBool(val) if err != nil { - return false, status.Errorf(codes.Internal, err.Error()) + return false, status.Error(codes.Internal, err.Error()) } return force, nil @@ -636,7 +636,7 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context, // it takes time for this operation. log.ErrorLog(ctx, err.Error()) - return nil, status.Errorf(codes.Aborted, err.Error()) + return nil, status.Error(codes.Aborted, err.Error()) } if info.GetState() != librbd.MirrorImageEnabled.String() { @@ -832,11 +832,11 @@ func (rs *ReplicationServer) GetVolumeReplicationInfo(ctx context.Context, if err != nil { switch { case errors.Is(err, corerbd.ErrImageNotFound): - err = status.Errorf(codes.NotFound, err.Error()) + err = status.Error(codes.NotFound, err.Error()) case errors.Is(err, util.ErrPoolNotFound): - err = status.Errorf(codes.NotFound, err.Error()) + err = status.Error(codes.NotFound, err.Error()) default: - err = status.Errorf(codes.Internal, err.Error()) + err = status.Error(codes.Internal, err.Error()) } return nil, err diff --git a/internal/liveness/liveness.go b/internal/liveness/liveness.go index 2c2fea4cd75..3b60b554cb2 100644 --- a/internal/liveness/liveness.go +++ b/internal/liveness/liveness.go @@ -64,7 +64,7 @@ func recordLiveness(endpoint, drivername string, pollTime, timeout time.Duration // register prometheus metrics err := prometheus.Register(liveness) if err != nil { - log.FatalLogMsg(err.Error()) + log.FatalLogMsg("%v", err.Error()) } csiConn, err := connlib.Connect(context.Background(), endpoint, liveMetricsManager) diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index ec230ec66dd..8283970f563 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -1122,9 +1122,9 @@ func (cs *ControllerServer) CreateSnapshot( err = status.Errorf(codes.NotFound, "source Volume ID %s not found", req.GetSourceVolumeId()) case errors.Is(err, util.ErrPoolNotFound): log.ErrorLog(ctx, "failed to get backend volume for %s: %v", req.GetSourceVolumeId(), err) - err = status.Errorf(codes.NotFound, err.Error()) + err = status.Error(codes.NotFound, err.Error()) default: - err = status.Errorf(codes.Internal, err.Error()) + err = status.Error(codes.Internal, err.Error()) } return nil, err @@ -1171,7 +1171,7 @@ func (cs *ControllerServer) CreateSnapshot( return nil, status.Error(codes.AlreadyExists, err.Error()) } - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Error(codes.Internal, err.Error()) } if found { return cloneFromSnapshot(ctx, rbdVol, rbdSnap, cr, req.GetParameters()) @@ -1253,7 +1253,7 @@ func cloneFromSnapshot( log.WarningLog(ctx, "failed undoing reservation of snapshot: %s %v", rbdSnap.RequestName, uErr) } - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Error(codes.Internal, err.Error()) } defer vol.Destroy(ctx) @@ -1265,14 +1265,14 @@ func cloneFromSnapshot( err = vol.flattenRbdImage(ctx, false, rbdHardMaxCloneDepth, rbdSoftMaxCloneDepth) if errors.Is(err, ErrFlattenInProgress) { // if flattening is in progress, return error and do not cleanup - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Error(codes.Internal, err.Error()) } else if err != nil { uErr := undoSnapshotCloning(ctx, rbdVol, rbdSnap, vol, cr) if uErr != nil { log.WarningLog(ctx, "failed undoing reservation of snapshot: %s %v", rbdSnap.RequestName, uErr) } - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Error(codes.Internal, err.Error()) } // Update snapshot-name/snapshot-namespace/snapshotcontent-name details on @@ -1566,9 +1566,9 @@ func (cs *ControllerServer) ControllerExpandVolume( err = status.Errorf(codes.NotFound, "volume ID %s not found", volID) case errors.Is(err, util.ErrPoolNotFound): log.ErrorLog(ctx, "failed to get backend volume for %s: %v", volID, err) - err = status.Errorf(codes.NotFound, err.Error()) + err = status.Error(codes.NotFound, err.Error()) default: - err = status.Errorf(codes.Internal, err.Error()) + err = status.Error(codes.Internal, err.Error()) } return nil, err diff --git a/internal/rbd/driver/driver.go b/internal/rbd/driver/driver.go index 7d58321caff..98b9ca40155 100644 --- a/internal/rbd/driver/driver.go +++ b/internal/rbd/driver/driver.go @@ -143,7 +143,7 @@ func (r *Driver) Run(conf *util.Config) { if k8s.RunsOnKubernetes() && conf.IsNodeServer { nodeLabels, err = k8s.GetNodeLabels(conf.NodeID) if err != nil { - log.FatalLogMsg(err.Error()) + log.FatalLogMsg("%v", err.Error()) } } @@ -157,19 +157,19 @@ func (r *Driver) Run(conf *util.Config) { if conf.IsNodeServer { topology, err = util.GetTopologyFromDomainLabels(conf.DomainLabels, conf.NodeID, conf.DriverName) if err != nil { - log.FatalLogMsg(err.Error()) + log.FatalLogMsg("%v", err.Error()) } r.ns = NewNodeServer(r.cd, conf.Vtype, nodeLabels, topology, crushLocationMap) var attr string attr, err = rbd.GetKrbdSupportedFeatures() if err != nil && !errors.Is(err, os.ErrNotExist) { - log.FatalLogMsg(err.Error()) + log.FatalLogMsg("%v", err.Error()) } var krbdFeatures uint krbdFeatures, err = rbd.HexStringToInteger(attr) if err != nil { - log.FatalLogMsg(err.Error()) + log.FatalLogMsg("%v", err.Error()) } rbd.SetGlobalInt("krbdFeatures", krbdFeatures) @@ -185,7 +185,7 @@ func (r *Driver) Run(conf *util.Config) { // configure CSI-Addons server and components err = r.setupCSIAddonsServer(conf) if err != nil { - log.FatalLogMsg(err.Error()) + log.FatalLogMsg("%v", err.Error()) } s := csicommon.NewNonBlockingGRPCServer() diff --git a/internal/util/topology_test.go b/internal/util/topology_test.go index 32ead00f921..170014c43d6 100644 --- a/internal/util/topology_test.go +++ b/internal/util/topology_test.go @@ -26,7 +26,7 @@ import ( func checkError(t *testing.T, msg string, err error) { t.Helper() if err == nil { - t.Errorf(msg) + t.Error(msg) } }