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 {
if errors.Is(err, ErrImageNotFound) {
// Need to check cloned info here not on createvolume,
if parentVol != nil {
found, cErr := rv.checkCloneImage(ctx, parentVol)
switch { switch {
case found && cErr == nil: case errors.Is(err, ErrImageNotFound) && parentVol != nil:
return true, nil // Need to check cloned info here not on createvolume
case cErr != nil: found, cErr := rv.checkCloneImage(ctx, parentVol)
if cErr != nil {
return false, cErr return false, cErr
} }
}
err = j.UndoReservation(ctx, rv.JournalPool, rv.Pool, if !found {
rv.RbdImageName, rv.RequestName) // image not found, undo the reservation
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
} }