cleanup: use errors.As() for error type checks

Replaces some remaining old-style error type checks with errors.As()

Signed-off-by: Sven Anderson <sven@redhat.com>
This commit is contained in:
Sven Anderson
2020-07-06 19:51:04 +02:00
committed by mergify[bot]
parent 310c36e319
commit 13f291dfc6
3 changed files with 29 additions and 15 deletions

View File

@ -155,7 +155,8 @@ func checkSnapCloneExists(ctx context.Context, parentVol *rbdVolume, rbdSnap *rb
if errors.As(err, &einf) {
err = parentVol.deleteSnapshot(ctx, rbdSnap)
if err != nil {
if _, ok := err.(ErrSnapNotFound); !ok {
var esnf ErrSnapNotFound
if !errors.As(err, &esnf) {
klog.Errorf(util.Log(ctx, "failed to delete snapshot %s: %v"), rbdSnap, err)
return false, err
}
@ -181,7 +182,8 @@ func checkSnapCloneExists(ctx context.Context, parentVol *rbdVolume, rbdSnap *rb
// check snapshot exists if not create it
_, err = vol.getSnapInfo(rbdSnap)
if _, ok := err.(ErrSnapNotFound); ok {
var esnf ErrSnapNotFound
if errors.As(err, &esnf) {
// create snapshot
sErr := vol.createSnapshot(ctx, rbdSnap)
if sErr != nil {