rbd: simplify error handling

This change replaces the sentinel errors in rbd module with
standard errors created with errors.New().

Related: #1203

Signed-off-by: Sven Anderson <sven@redhat.com>
This commit is contained in:
Sven Anderson
2020-07-10 03:05:42 +02:00
committed by mergify[bot]
parent dba2c27bcb
commit 92884f56f4
7 changed files with 61 additions and 167 deletions

View File

@ -66,16 +66,14 @@ func createRBDClone(ctx context.Context, parentVol, cloneRbdVol *rbdVolume, snap
func cleanUpSnapshot(ctx context.Context, parentVol *rbdVolume, rbdSnap *rbdSnapshot, rbdVol *rbdVolume, cr *util.Credentials) error {
err := parentVol.deleteSnapshot(ctx, rbdSnap)
if err != nil {
var esnf ErrSnapNotFound
if !errors.As(err, &esnf) {
if !errors.Is(err, ErrSnapNotFound) {
klog.Errorf(util.Log(ctx, "failed to delete snapshot: %v"), err)
return err
}
}
err = deleteImage(ctx, rbdVol, cr)
if err != nil {
var einf ErrImageNotFound
if !errors.As(err, &einf) {
if !errors.Is(err, ErrImageNotFound) {
klog.Errorf(util.Log(ctx, "failed to delete rbd image: %s/%s with error: %v"), rbdVol.Pool, rbdVol.VolName, err)
return err
}