From c851b69160e43f4f238a039f35eabf8fe34962b6 Mon Sep 17 00:00:00 2001 From: Yati Padia Date: Fri, 25 Jun 2021 17:07:24 +0530 Subject: [PATCH] cleanup: error is not nil but returns nil In few places the error is not nil still it returns nil. Updates: #1586 Signed-off-by: Yati Padia --- e2e/pvc.go | 2 +- e2e/rbd_helper.go | 2 +- e2e/utils.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/pvc.go b/e2e/pvc.go index 2ad8d22ed..8a9e652e7 100644 --- a/e2e/pvc.go +++ b/e2e/pvc.go @@ -68,7 +68,7 @@ func createPVCAndvalidatePV(c kubernetes.Interface, pvc *v1.PersistentVolumeClai } err = e2epv.WaitOnPVandPVC(c, pvc.Namespace, pv, pvc) if err != nil { - return false, nil + return false, fmt.Errorf("failed to wait for the pv and pvc to bind: %w", err) } return true, nil }) diff --git a/e2e/rbd_helper.go b/e2e/rbd_helper.go index b8a8e9d15..a5577662f 100644 --- a/e2e/rbd_helper.go +++ b/e2e/rbd_helper.go @@ -44,7 +44,7 @@ func createRBDStorageClass( scPath := fmt.Sprintf("%s/%s", rbdExamplePath, "storageclass.yaml") sc, err := getStorageClass(scPath) if err != nil { - return nil + return fmt.Errorf("failed to get sc: %w", err) } if name != "" { sc.Name = name diff --git a/e2e/utils.go b/e2e/utils.go index ff4448a8b..698dbf6b6 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -311,7 +311,7 @@ func validateNormalUserPVCAccess(pvcPath string, f *framework.Framework) error { } _, stdErr, err := execCommandInPod(f, "echo testing > /target/testing", app.Namespace, &opt) if err != nil { - return nil + return fmt.Errorf("failed to exec command in pod: %w", err) } if stdErr != "" { return fmt.Errorf("failed to touch a file as non-root user %v", stdErr) @@ -395,7 +395,7 @@ func checkDataPersist(pvcPath, appPath string, f *framework.Framework) error { _, stdErr, err := execCommandInPod(f, fmt.Sprintf("echo %s > %s", data, filePath), app.Namespace, &opt) if err != nil { - return nil + return fmt.Errorf("failed to exec command in pod: %w", err) } if stdErr != "" { return fmt.Errorf("failed to write data to a file %v", stdErr)