Skip to content

Commit

Permalink
rbd: fix bug in rbdVol.Exists() in PVC-PVC clone case
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Rakshith-R authored and mergify[bot] committed Feb 18, 2025
1 parent 8cdfb92 commit b05d467
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions internal/rbd/rbd_journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,24 +297,28 @@ func (rv *rbdVolume) Exists(ctx context.Context, parentVol *rbdVolume) (bool, er
requestSize := rv.VolSize
// Fetch on-disk image attributes and compare against request
err = rv.getImageInfo()
if err != nil {
if errors.Is(err, util.ErrImageNotFound) {
// Need to check cloned info here not on createvolume,
if parentVol != nil {
found, cErr := rv.checkCloneImage(ctx, parentVol)
switch {
case found && cErr == nil:
return true, nil
case cErr != nil:
return false, cErr
}
}
err = j.UndoReservation(ctx, rv.JournalPool, rv.Pool,
rv.RbdImageName, rv.RequestName)
switch {
case errors.Is(err, util.ErrImageNotFound) && parentVol != nil:
// Need to check cloned info here not on createvolume
found, cErr := rv.checkCloneImage(ctx, parentVol)
if cErr != nil {
return false, cErr
}

if !found {
// image not found, undo the reservation
err = j.UndoReservation(ctx, rv.JournalPool, rv.Pool, rv.RbdImageName, rv.RequestName)

return false, err
}

case errors.Is(err, util.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
}

Expand Down

0 comments on commit b05d467

Please sign in to comment.