cleanup: use errors.As() in cephfs.checkVolExists()

See-also: https://github.com/golang/go/wiki/ErrorValueFAQ#how-should-i-change-my-error-handling-code-to-work-with-the-new-features
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-06-25 10:35:19 +02:00 committed by mergify[bot]
parent 72c74f5f8a
commit ad04e0d8c4

View File

@ -18,6 +18,7 @@ package cephfs
import (
"context"
"errors"
"github.com/ceph/ceph-csi/internal/util"
@ -73,7 +74,8 @@ func checkVolExists(ctx context.Context, volOptions *volumeOptions, secret map[s
_, err = getVolumeRootPathCeph(ctx, volOptions, cr, volumeID(vid.FsSubvolName))
if err != nil {
if _, ok := err.(ErrVolumeNotFound); ok {
var evnf ErrVolumeNotFound
if errors.As(err, &evnf) {
err = j.UndoReservation(ctx, volOptions.MetadataPool,
volOptions.MetadataPool, vid.FsSubvolName, volOptions.RequestName)
return nil, err