mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rbd: retain intermediate RBD snapshot on temp image
Currently, Ceph-CSI deletes intermediate RBD snapshot on temporary cloned images (`csi-vol-xxxx-temp@csi-vol-xxxx`) which is the parent of the final clone image. The parent-child mirroring requires both the parent and child images to be present (i.e, not in trash). This commit makes enhancement to `createRBDClone` function by introducing `deleteSnap` parameter. If `deleteSnap` is true, the snapshot is deleted after the clone is created. This is required to support mirroring of child image with its parent image. Signed-off-by: Praveen M <m.praveen@ibm.com>
This commit is contained in:
@ -750,7 +750,21 @@ func (ri *rbdImage) trashRemoveImage(ctx context.Context) error {
|
||||
// DeleteTempImage deletes the temporary image created for volume datasource.
|
||||
func (rv *rbdVolume) DeleteTempImage(ctx context.Context) error {
|
||||
tempClone := rv.generateTempClone()
|
||||
err := tempClone.Delete(ctx)
|
||||
snap := &rbdSnapshot{}
|
||||
defer snap.Destroy(ctx)
|
||||
|
||||
snap.RbdImageName = tempClone.RbdImageName
|
||||
snap.RbdSnapName = rv.RbdImageName
|
||||
snap.Pool = rv.Pool
|
||||
snap.RadosNamespace = rv.RadosNamespace
|
||||
err := tempClone.deleteSnapshot(ctx, snap)
|
||||
if err != nil {
|
||||
if !errors.Is(err, util.ErrImageNotFound) && !errors.Is(err, ErrSnapNotFound) {
|
||||
return fmt.Errorf("failed to delete snapshot %q: %w", snap, err)
|
||||
}
|
||||
}
|
||||
|
||||
err = tempClone.Delete(ctx)
|
||||
if err != nil {
|
||||
if errors.Is(err, util.ErrImageNotFound) {
|
||||
return tempClone.ensureImageCleanup(ctx)
|
||||
|
Reference in New Issue
Block a user