mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
cleanup: use errors.As() in rbdVolume.Exists() and rbd.checkSnapExists()
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:
parent
d4dad7c189
commit
a47cfbc6c8
@ -150,7 +150,8 @@ func checkSnapCloneExists(ctx context.Context, parentVol *rbdVolume, rbdSnap *rb
|
||||
// Fetch on-disk image attributes
|
||||
err = vol.getImageInfo()
|
||||
if err != nil {
|
||||
if _, ok := err.(ErrImageNotFound); ok {
|
||||
var esnf ErrSnapNotFound
|
||||
if errors.As(err, &esnf) {
|
||||
err = parentVol.deleteSnapshot(ctx, rbdSnap)
|
||||
if err != nil {
|
||||
if _, ok := err.(ErrSnapNotFound); !ok {
|
||||
@ -272,7 +273,8 @@ func (rv *rbdVolume) Exists(ctx context.Context) (bool, error) {
|
||||
// Fetch on-disk image attributes and compare against request
|
||||
err = rv.getImageInfo()
|
||||
if err != nil {
|
||||
if _, ok := err.(ErrImageNotFound); ok {
|
||||
var einf ErrImageNotFound
|
||||
if errors.As(err, &einf) {
|
||||
err = j.UndoReservation(ctx, rv.JournalPool, rv.Pool,
|
||||
rv.RbdImageName, rv.RequestName)
|
||||
return false, err
|
||||
|
Loading…
Reference in New Issue
Block a user