mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-05-21 14:56:41 +00:00
rbd: rearrange the cleanup order incase clone fails
in case of clone failure, we need to first delete the clone and the snapshot from which we created the clone, then as part of cleanup we need to remove the temporary cloned image and the temporary snapshot created on the parent image. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com> (cherry picked from commit 38892c3068cfacf1f3b9595b681d30e31722ec2a)
This commit is contained in:
parent
45c8d178b2
commit
8e267b3806
@ -176,6 +176,13 @@ func (rv *rbdVolume) createCloneFromImage(ctx context.Context, parentVol *rbdVol
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err != nil || errClone != nil {
|
||||
cErr := cleanUpSnapshot(ctx, tempClone, cloneSnap, rv, rv.conn.Creds)
|
||||
if cErr != nil {
|
||||
util.ErrorLog(ctx, "failed to cleanup image %s or snapshot %s: %v", cloneSnap, tempClone, cErr)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil || errFlatten != nil {
|
||||
if !errors.Is(errFlatten, ErrFlattenInProgress) {
|
||||
// cleanup snapshot
|
||||
@ -185,12 +192,6 @@ func (rv *rbdVolume) createCloneFromImage(ctx context.Context, parentVol *rbdVol
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil || errClone != nil {
|
||||
cErr := cleanUpSnapshot(ctx, tempClone, cloneSnap, rv, rv.conn.Creds)
|
||||
if cErr != nil {
|
||||
util.ErrorLog(ctx, "failed to cleanup image %s or snapshot %s: %v", cloneSnap, tempClone, cErr)
|
||||
}
|
||||
}
|
||||
}()
|
||||
// flatten clone
|
||||
errFlatten = tempClone.flattenRbdImage(ctx, rv.conn.Creds, false, rbdHardMaxCloneDepth, rbdSoftMaxCloneDepth)
|
||||
|
Loading…
x
Reference in New Issue
Block a user