Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbd: reserveSnap() should cleanup its state in case of a failure #4945

Closed
nixpanic opened this issue Nov 5, 2024 · 0 comments · Fixed by #4946
Closed

rbd: reserveSnap() should cleanup its state in case of a failure #4945

nixpanic opened this issue Nov 5, 2024 · 0 comments · Fixed by #4946
Assignees
Labels
cleanup component/rbd Issues related to RBD

Comments

@nixpanic
Copy link
Member

nixpanic commented Nov 5, 2024

reserveSnap() could set certain attributes of rbdSnap, but can fail later on. In case of a failure, attributes set in rbdSnap may not be consistent. The function should cleanup its state in case of a failure (UndoReserveName()), and only change rbdSnap attributes on success.

rbdSnap.ReservedID, rbdSnap.RbdSnapName, err = j.ReserveName(
ctx, rbdSnap.JournalPool, journalPoolID, rbdSnap.Pool, imagePoolID,
rbdSnap.RequestName, rbdSnap.NamePrefix, rbdVol.RbdImageName, kmsID, rbdSnap.ReservedID, rbdVol.Owner,
"", encryptionType)
if err != nil {
return err
}
rbdSnap.VolID, err = util.GenerateVolID(ctx, rbdSnap.Monitors, cr, imagePoolID, rbdSnap.Pool,
rbdSnap.ClusterID, rbdSnap.ReservedID)
if err != nil {
return err
}
log.DebugLog(ctx, "generated Volume ID (%s) and image name (%s) for request name (%s)",
rbdSnap.VolID, rbdSnap.RbdSnapName, rbdSnap.RequestName)
return nil
}

Originally posted by @iPraveenParihar in #4502 (comment)

nixpanic added a commit to nixpanic/ceph-csi that referenced this issue Nov 6, 2024
`reserveSnap()` can potentially fail halfway through, in that case it
needs to undo the snapshot reservation and restore modified attributes
of the snapshot.

Fixes: ceph#4945
Signed-off-by: Niels de Vos <ndevos@ibm.com>
@nixpanic nixpanic added cleanup component/rbd Issues related to RBD labels Nov 6, 2024
@nixpanic nixpanic self-assigned this Nov 6, 2024
@mergify mergify bot closed this as completed in #4946 Nov 11, 2024
@mergify mergify bot closed this as completed in f3d40f9 Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup component/rbd Issues related to RBD
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant