diff --git a/e2e/cephfs.go b/e2e/cephfs.go index d36873cfeb8..14d0a967a37 100644 --- a/e2e/cephfs.go +++ b/e2e/cephfs.go @@ -218,7 +218,7 @@ var _ = Describe(cephfsType, func() { err = createSubvolumegroup(f, fileSystemName, subvolumegroup) if err != nil { - framework.Failf("%v", err) + framework.Failf("failed to create subvolumegroup %s: %v", subvolumegroup, err) } }) @@ -261,7 +261,7 @@ var _ = Describe(cephfsType, func() { err = deleteSubvolumegroup(f, fileSystemName, subvolumegroup) if err != nil { - framework.Failf("%v", err) + framework.Failf("failed to delete subvolumegroup %s: %v", subvolumegroup, err) } if deployCephFS { @@ -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("ensureStatSucceeds failed for pod %q: %v", deplPods[i].Name, 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("failed to delete pod %s: %v", pod2Name, 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("timeout waiting for deployment %s: %v", depl.Name, 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("ensureStatSucceeds failed for pod %q: %v", pod2Name, err.Error()) } // Delete created resources. @@ -967,11 +967,11 @@ var _ = Describe(cephfsType, func() { err = createSubvolumegroup(f, fileSystemName, subvolgrp1) if err != nil { - framework.Failf("%v", err) + framework.Failf("failed to create subvolumegroup %s: %v", subvolgrp1, err) } err = createSubvolumegroup(f, fileSystemName, subvolgrp2) if err != nil { - framework.Failf("%v", err) + framework.Failf("failed to create subvolumegroup %s: %v", subvolgrp2, err) } err = createCustomConfigMap(f.ClientSet, cephFSDirPath, clusterInfo) if err != nil { @@ -1019,11 +1019,11 @@ var _ = Describe(cephfsType, func() { } err = deleteSubvolumegroup(f, fileSystemName, subvolgrp1) if err != nil { - framework.Failf("%v", err) + framework.Failf("failed to delete subvolumegroup %s: %v", subvolgrp1, err) } err = deleteSubvolumegroup(f, fileSystemName, subvolgrp2) if err != nil { - framework.Failf("%v", err) + framework.Failf("failed to delete subvolumegroup %s: %v", subvolgrp2, err) } err = deleteConfigMap(cephFSDirPath) if err != nil { @@ -1076,14 +1076,15 @@ var _ = Describe(cephfsType, func() { } filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" + cmd := "echo 'Hello World' >" + filePath _, stdErr := execCommandInPodAndAllowFail( f, - "echo 'Hello World' >"+filePath, + cmd, app.Namespace, &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("failed to execute command %s: %v", cmd, stdErr) } // delete PVC and app @@ -2406,14 +2407,15 @@ var _ = Describe(cephfsType, func() { } filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" + cmd := "echo 'Hello World' > " + filePath _, stdErr := execCommandInPodAndAllowFail( f, - "echo 'Hello World' > "+filePath, + cmd, app.Namespace, &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("failed to execute command %s: %v", cmd, stdErr) } // delete cloned ROX pvc and app diff --git a/e2e/nfs.go b/e2e/nfs.go index a85004b50a4..31dd60ba59b 100644 --- a/e2e/nfs.go +++ b/e2e/nfs.go @@ -279,7 +279,7 @@ var _ = Describe("nfs", func() { err = createSubvolumegroup(f, fileSystemName, subvolumegroup) if err != nil { - framework.Failf("%v", err) + framework.Failf("failed to create subvolumegroup %s: %v", subvolumegroup, err) } }) @@ -320,7 +320,7 @@ var _ = Describe("nfs", func() { } err = deleteSubvolumegroup(f, fileSystemName, subvolumegroup) if err != nil { - framework.Failf("%v", err) + framework.Failf("failed to delete subvolumegroup %s: %v", subvolumegroup, err) } if deployNFS { @@ -607,14 +607,15 @@ var _ = Describe("nfs", func() { } filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" + cmd := "echo 'Hello World' > " + filePath _, stdErr := execCommandInPodAndAllowFail( f, - "echo 'Hello World' > "+filePath, + cmd, app.Namespace, &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("failed to execute command %s: %v", cmd, stdErr) } // delete PVC and app diff --git a/e2e/rbd.go b/e2e/rbd.go index 55bfab877f5..fddba2937d5 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("failed to execute command %s: %v", cmd, 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("failed to execute command %s: %v", cmd, stdErr) } } err = deletePVCAndDeploymentApp(f, pvcClone, appClone) @@ -3350,14 +3350,15 @@ var _ = Describe("RBD", func() { } filePath := appClone.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" + cmd := "echo 'Hello World' > " + filePath _, stdErr := execCommandInPodAndAllowFail( f, - "echo 'Hello World' > "+filePath, + cmd, appClone.Namespace, &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("failed to execute command %s: %v", cmd, stdErr) } } @@ -3464,14 +3465,15 @@ var _ = Describe("RBD", func() { } filePath := appClone.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" + cmd := "echo 'Hello World' > " + filePath _, stdErr := execCommandInPodAndAllowFail( f, - "echo 'Hello World' > "+filePath, + cmd, appClone.Namespace, &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("failed to execute command %s: %v", cmd, stdErr) } } @@ -4126,14 +4128,15 @@ var _ = Describe("RBD", func() { } filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" + cmd := "echo 'Hello World' > " + filePath _, stdErr := execCommandInPodAndAllowFail( f, - "echo 'Hello World' > "+filePath, + cmd, app.Namespace, &opt) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) if !strings.Contains(stdErr, readOnlyErr) { - framework.Failf(stdErr) + framework.Failf("failed to execute command %s: %v", cmd, 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/e2e/utils.go b/e2e/utils.go index 608f6e600fe..04cc03f2b05 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -251,7 +251,7 @@ func validateOmapCount(f *framework.Framework, count int, driver, pool, mode str framework.Logf("additional debug info: rados ls command output: %s, stdErr: %s", stdOut, stdErr) } } - framework.Failf("%v", saveErr) + framework.Fail(saveErr.Error()) } } } 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) } }