rbd: fix bug in rbdVol.Exists() in PVC-PVC clone case

This commit fixes a bug in rbdVol.Exists() which caused
VolID not to be set in PVC-PVC clone case.

Signed-off-by: Rakshith R <rar@redhat.com>
(cherry picked from commit b05d467679)

# Conflicts:
#	internal/rbd/rbd_journal.go
This commit is contained in:
Rakshith R 2025-02-18 15:04:05 +05:30 committed by mergify[bot]
parent 000b5c488d
commit 43c3cc8de6

View File

@ -297,24 +297,28 @@ func (rv *rbdVolume) Exists(ctx context.Context, parentVol *rbdVolume) (bool, er
requestSize := rv.VolSize requestSize := rv.VolSize
// Fetch on-disk image attributes and compare against request // Fetch on-disk image attributes and compare against request
err = rv.getImageInfo() err = rv.getImageInfo()
if err != nil { switch {
if errors.Is(err, ErrImageNotFound) { case errors.Is(err, ErrImageNotFound) && parentVol != nil:
// Need to check cloned info here not on createvolume, // Need to check cloned info here not on createvolume
if parentVol != nil { found, cErr := rv.checkCloneImage(ctx, parentVol)
found, cErr := rv.checkCloneImage(ctx, parentVol) if cErr != nil {
switch { return false, cErr
case found && cErr == nil: }
return true, nil
case cErr != nil: if !found {
return false, cErr // image not found, undo the reservation
} err = j.UndoReservation(ctx, rv.JournalPool, rv.Pool, rv.RbdImageName, rv.RequestName)
}
err = j.UndoReservation(ctx, rv.JournalPool, rv.Pool,
rv.RbdImageName, rv.RequestName)
return false, err return false, err
} }
case errors.Is(err, ErrImageNotFound) && parentVol == nil:
// image not found, undo the reservation
err = j.UndoReservation(ctx, rv.JournalPool, rv.Pool, rv.RbdImageName, rv.RequestName)
return false, err
case err != nil:
return false, err return false, err
} }