rbd: undo reservation incase of errors

If cephcsi encounters any error after
reservation, as a cleanup operation
it should revert back the reservation.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-12-04 13:26:53 +05:30 committed by mergify[bot]
parent 99dbe27921
commit c40872df00

View File

@ -570,6 +570,15 @@ func RegenerateJournal(imageName, volumeID, pool, journalPool, requestName strin
return err return err
} }
defer func() {
if err != nil {
undoErr := j.UndoReservation(ctx, rbdVol.JournalPool, rbdVol.Pool,
rbdVol.RbdImageName, rbdVol.RequestName)
if undoErr != nil {
util.ErrorLog(ctx, "failed to undo reservation %s: %v", rbdVol, undoErr)
}
}
}()
rbdVol.VolID, err = util.GenerateVolID(ctx, rbdVol.Monitors, cr, imagePoolID, rbdVol.Pool, rbdVol.VolID, err = util.GenerateVolID(ctx, rbdVol.Monitors, cr, imagePoolID, rbdVol.Pool,
rbdVol.ClusterID, rbdVol.ReservedID, volIDVersion) rbdVol.ClusterID, rbdVol.ReservedID, volIDVersion)
if err != nil { if err != nil {