diff --git a/e2e/utils.go b/e2e/utils.go index 36c63ef57..bc98fbd87 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "encoding/json" + "errors" "fmt" "io/ioutil" "regexp" @@ -177,7 +178,7 @@ func waitForDeploymentComplete(name, ns string, c clientset.Interface, t int) er return false, nil }) - if err == wait.ErrWaitTimeout { + if errors.Is(err, wait.ErrWaitTimeout) { err = fmt.Errorf("%s", reason) } if err != nil { diff --git a/internal/rbd/rbd_attach.go b/internal/rbd/rbd_attach.go index 8e77db857..9d07dc180 100644 --- a/internal/rbd/rbd_attach.go +++ b/internal/rbd/rbd_attach.go @@ -19,6 +19,7 @@ package rbd import ( "context" "encoding/json" + "errors" "fmt" "os" "strconv" @@ -257,7 +258,7 @@ func waitForrbdImage(ctx context.Context, backoff wait.Backoff, volOptions *rbdV return !used, nil }) // return error if rbd image has not become available for the specified timeout - if err == wait.ErrWaitTimeout { + if errors.Is(err, wait.ErrWaitTimeout) { return fmt.Errorf("rbd image %s is still being used", imagePath) } // return error if any other errors were encountered during waiting for the image to become available diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index b7ae4d5ee..ade55edde 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -267,7 +267,7 @@ func rbdStatus(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) (boo output = string(cmd) if err, ok := err.(*exec.Error); ok { - if err.Err == exec.ErrNotFound { + if errors.Is(err.Err, exec.ErrNotFound) { klog.Errorf(util.Log(ctx, "rbd cmd not found")) // fail fast if command not found return false, output, err diff --git a/internal/util/nodecache.go b/internal/util/nodecache.go index c8a60fd0d..94232c49a 100644 --- a/internal/util/nodecache.go +++ b/internal/util/nodecache.go @@ -62,7 +62,7 @@ func (nc *NodeCache) ForAll(pattern string, destObj interface{}, f ForAllFunc) e cachePath := path.Join(nc.BasePath, nc.CacheDir) for _, file := range files { err = decodeObj(cachePath, pattern, file, destObj) - if err == errDec { + if errors.Is(err, errDec) { continue } else if err == nil { if err = f(strings.TrimSuffix(file.Name(), filepath.Ext(file.Name()))); err != nil {