rbd: pass parent volume to undoSnapshotCloning function

as we are supporting the creation of clone to a new
pool we need to pass the correct parent volume
to cleanup the snapshot on parent volume.

Co-authored-by: Madhu Rajanna <madhupr007@gmail.com>
Signed-off-by: Yug <yuggupta27@gmail.com>
This commit is contained in:
Yug 2020-12-01 15:12:53 +05:30 committed by mergify[bot]
parent 961c1d12fd
commit e699318acc
2 changed files with 6 additions and 6 deletions

View File

@ -844,7 +844,7 @@ func cloneFromSnapshot(ctx context.Context, rbdVol *rbdVolume, rbdSnap *rbdSnaps
vol := generateVolFromSnap(rbdSnap) vol := generateVolFromSnap(rbdSnap)
err := vol.Connect(cr) err := vol.Connect(cr)
if err != nil { if err != nil {
uErr := undoSnapshotCloning(ctx, vol, rbdSnap, vol, cr) uErr := undoSnapshotCloning(ctx, rbdVol, rbdSnap, vol, cr)
if uErr != nil { if uErr != nil {
util.WarningLog(ctx, "failed undoing reservation of snapshot: %s %v", rbdSnap.RequestName, uErr) util.WarningLog(ctx, "failed undoing reservation of snapshot: %s %v", rbdSnap.RequestName, uErr)
} }
@ -868,7 +868,7 @@ func cloneFromSnapshot(ctx context.Context, rbdVol *rbdVolume, rbdSnap *rbdSnaps
if errors.Is(err, ErrFlattenInProgress) { if errors.Is(err, ErrFlattenInProgress) {
readyToUse = false readyToUse = false
} else if err != nil { } else if err != nil {
uErr := undoSnapshotCloning(ctx, vol, rbdSnap, vol, cr) uErr := undoSnapshotCloning(ctx, rbdVol, rbdSnap, vol, cr)
if uErr != nil { if uErr != nil {
util.WarningLog(ctx, "failed undoing reservation of snapshot: %s %v", rbdSnap.RequestName, uErr) util.WarningLog(ctx, "failed undoing reservation of snapshot: %s %v", rbdSnap.RequestName, uErr)
} }

View File

@ -167,7 +167,7 @@ func checkSnapCloneExists(ctx context.Context, parentVol *rbdVolume, rbdSnap *rb
return false, err return false, err
} }
} }
err = undoSnapshotCloning(ctx, vol, rbdSnap, vol, cr) err = undoSnapshotCloning(ctx, parentVol, rbdSnap, vol, cr)
} }
return false, err return false, err
} }
@ -193,7 +193,7 @@ func checkSnapCloneExists(ctx context.Context, parentVol *rbdVolume, rbdSnap *rb
sErr := vol.createSnapshot(ctx, rbdSnap) sErr := vol.createSnapshot(ctx, rbdSnap)
if sErr != nil { if sErr != nil {
util.ErrorLog(ctx, "failed to create snapshot %s: %v", rbdSnap, sErr) util.ErrorLog(ctx, "failed to create snapshot %s: %v", rbdSnap, sErr)
err = undoSnapshotCloning(ctx, vol, rbdSnap, vol, cr) err = undoSnapshotCloning(ctx, parentVol, rbdSnap, vol, cr)
return false, err return false, err
} }
} }
@ -205,13 +205,13 @@ func checkSnapCloneExists(ctx context.Context, parentVol *rbdVolume, rbdSnap *rb
sErr := vol.getImageID() sErr := vol.getImageID()
if sErr != nil { if sErr != nil {
util.ErrorLog(ctx, "failed to get image id %s: %v", vol, sErr) util.ErrorLog(ctx, "failed to get image id %s: %v", vol, sErr)
err = undoSnapshotCloning(ctx, vol, rbdSnap, vol, cr) err = undoSnapshotCloning(ctx, parentVol, rbdSnap, vol, cr)
return false, err return false, err
} }
sErr = j.StoreImageID(ctx, vol.JournalPool, vol.ReservedID, vol.ImageID) sErr = j.StoreImageID(ctx, vol.JournalPool, vol.ReservedID, vol.ImageID)
if sErr != nil { if sErr != nil {
util.ErrorLog(ctx, "failed to store volume id %s: %v", vol, sErr) util.ErrorLog(ctx, "failed to store volume id %s: %v", vol, sErr)
err = undoSnapshotCloning(ctx, vol, rbdSnap, vol, cr) err = undoSnapshotCloning(ctx, parentVol, rbdSnap, vol, cr)
return false, err return false, err
} }
} }