mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
cleanup: resolve errorlint issues
This commit resolves errorlint issues which checks for the code that will cause problems with the error wrapping scheme. Updates: #1586 Signed-off-by: Yati Padia <ypadia@redhat.com>
This commit is contained in:
parent
bfda5fa57f
commit
3469dfc753
@ -271,13 +271,13 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
|
||||
wgErrs := make([]error, totalCount)
|
||||
pvc, err := loadPVC(pvcPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load PVC with error %v", err)
|
||||
return fmt.Errorf("failed to load PVC with error %w", err)
|
||||
}
|
||||
|
||||
pvc.Namespace = f.UniqueName
|
||||
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create PVC with error %v", err)
|
||||
return fmt.Errorf("failed to create PVC with error %w", err)
|
||||
}
|
||||
validateRBDImageCount(f, 1, defaultRBDPool)
|
||||
snap := getSnapshot(snapshotPath)
|
||||
@ -301,7 +301,7 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
|
||||
// delete parent pvc
|
||||
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete PVC with error %v", err)
|
||||
return fmt.Errorf("failed to delete PVC with error %w", err)
|
||||
}
|
||||
|
||||
// validate the rbd images created for snapshots
|
||||
@ -309,11 +309,11 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc,
|
||||
|
||||
pvcClone, err := loadPVC(pvcClonePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load PVC with error %v", err)
|
||||
return fmt.Errorf("failed to load PVC with error %w", err)
|
||||
}
|
||||
appClone, err := loadApp(appClonePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load application with error %v", err)
|
||||
return fmt.Errorf("failed to load application with error %w", err)
|
||||
}
|
||||
pvcClone.Namespace = f.UniqueName
|
||||
// if request is to create clone with different storage class
|
||||
|
@ -119,7 +119,7 @@ func deleteSnapshot(snap *snapapi.VolumeSnapshot, t int) error {
|
||||
}
|
||||
if !apierrs.IsNotFound(err) {
|
||||
return false, fmt.Errorf(
|
||||
"get on deleted snapshot %v failed with error other than \"not found\": %v",
|
||||
"get on deleted snapshot %v failed with error other than \"not found\": %w",
|
||||
name,
|
||||
err)
|
||||
}
|
||||
|
18
e2e/utils.go
18
e2e/utils.go
@ -1035,17 +1035,17 @@ func validateController(f *framework.Framework, pvcPath, appPath, scPath string)
|
||||
// create storageclass with retain
|
||||
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, retainPolicy)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create storageclass with error %v", err)
|
||||
return fmt.Errorf("failed to create storageclass: %w", err)
|
||||
}
|
||||
|
||||
// create pvc
|
||||
pvc, err := loadPVC(pvcPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load PVC with error %v", err)
|
||||
return fmt.Errorf("failed to load PVC: %w", err)
|
||||
}
|
||||
resizePvc, err := loadPVC(pvcPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load PVC with error %v", err)
|
||||
return fmt.Errorf("failed to load PVC: %w", err)
|
||||
}
|
||||
resizePvc.Namespace = f.UniqueName
|
||||
|
||||
@ -1053,21 +1053,21 @@ func validateController(f *framework.Framework, pvcPath, appPath, scPath string)
|
||||
pvc.Namespace = f.UniqueName
|
||||
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create PVC with error %v", err)
|
||||
return fmt.Errorf("failed to create PVC: %w", err)
|
||||
}
|
||||
// get pvc and pv object
|
||||
pvc, pv, err := getPVCAndPV(f.ClientSet, pvc.Name, pvc.Namespace)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get PVC with error %v", err)
|
||||
return fmt.Errorf("failed to get PVC: %w", err)
|
||||
}
|
||||
// Recreate storageclass with delete policy
|
||||
err = deleteResource(scPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete storageclass with error %v", err)
|
||||
return fmt.Errorf("failed to delete storageclass: %w", err)
|
||||
}
|
||||
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create storageclass with error %v", err)
|
||||
return fmt.Errorf("failed to create storageclass: %w", err)
|
||||
}
|
||||
// delete omap data
|
||||
err = deletePVCImageJournalInPool(f, pvc, poolName)
|
||||
@ -1081,7 +1081,7 @@ func validateController(f *framework.Framework, pvcPath, appPath, scPath string)
|
||||
// delete pvc and pv
|
||||
err = deletePVCAndPV(f.ClientSet, pvc, pv, deployTimeout)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete PVC or PV with error %v", err)
|
||||
return fmt.Errorf("failed to delete PVC or PV: %w", err)
|
||||
}
|
||||
// create pvc and pv with application
|
||||
pv.Spec.ClaimRef = nil
|
||||
@ -1091,7 +1091,7 @@ func validateController(f *framework.Framework, pvcPath, appPath, scPath string)
|
||||
pv.ResourceVersion = ""
|
||||
err = createPVCAndPV(f.ClientSet, pvc, pv)
|
||||
if err != nil {
|
||||
e2elog.Failf("failed to create PVC or PV with error %v", err)
|
||||
e2elog.Failf("failed to create PVC or PV: %v", err)
|
||||
}
|
||||
// bind PVC to application
|
||||
app, err := loadApp(appPath)
|
||||
|
@ -325,7 +325,7 @@ func createPath(ctx context.Context, volOpt *rbdVolume, device string, cr *util.
|
||||
util.WarningLog(ctx, "rbd: %s unmap error %v", imagePath, detErr)
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("rbd: map failed with error %v, rbd error output: %s", err, stderr)
|
||||
return "", fmt.Errorf("rbd: map failed with error %w, rbd error output: %s", err, stderr)
|
||||
}
|
||||
devicePath := strings.TrimSuffix(stdout, "\n")
|
||||
|
||||
|
@ -265,7 +265,7 @@ func createImage(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) er
|
||||
if pOpts.isEncrypted() {
|
||||
err = pOpts.setupEncryption(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to setup encryption for image %s: %v", pOpts, err)
|
||||
return fmt.Errorf("failed to setup encryption for image %s: %w", pOpts, err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1579,10 +1579,10 @@ func (ri *rbdImage) setThinProvisioned() error {
|
||||
// the expansion can be allocated too.
|
||||
func (ri *rbdImage) isThickProvisioned() (bool, error) {
|
||||
value, err := ri.GetMetadata(thickProvisionMetaKey)
|
||||
if err == librbd.ErrNotFound {
|
||||
if errors.Is(err, librbd.ErrNotFound) {
|
||||
// check if the image is having deprecated metadata key.
|
||||
value, err = ri.GetMetadata(deprecatedthickProvisionMetaKey)
|
||||
if err == librbd.ErrNotFound {
|
||||
if errors.Is(err, librbd.ErrNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
// If we reach here means the image has deprecated metakey set. Set the
|
||||
|
@ -18,6 +18,7 @@ package util
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@ -78,7 +79,7 @@ func GetPIDLimit() (int, error) {
|
||||
defer f.Close() // #nosec: error on close is not critical here
|
||||
|
||||
maxPidsStr, err := bufio.NewReader(f).ReadString('\n')
|
||||
if err != nil && err != io.EOF {
|
||||
if err != nil && !errors.Is(err, io.EOF) {
|
||||
return 0, err
|
||||
}
|
||||
maxPidsStr = strings.TrimRight(maxPidsStr, "\n")
|
||||
|
@ -151,7 +151,7 @@ func GetTopologyFromRequest(
|
||||
err := json.Unmarshal([]byte(strings.Replace(topologyPoolsStr, "\n", " ", -1)), &topologyPools)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf(
|
||||
"failed to parse JSON encoded topology constrained pools parameter (%s): %v",
|
||||
"failed to parse JSON encoded topology constrained pools parameter (%s): %w",
|
||||
topologyPoolsStr,
|
||||
err)
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ func TestFindPoolAndTopology(t *testing.T) {
|
||||
|
||||
checkOutput := func(err error, poolName string, topoSegment map[string]string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("expected success, got err (%v)", err)
|
||||
return fmt.Errorf("expected success, got err (%w)", err)
|
||||
}
|
||||
if poolName != pool1 || !(len(topoSegment) == 2) &&
|
||||
topoSegment[topologyPrefix+"/"+label1] == l1Value1 &&
|
||||
|
Loading…
Reference in New Issue
Block a user