mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +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>
This commit is contained in:
parent
a7b65087af
commit
38892c3068
@ -176,6 +176,13 @@ func (rv *rbdVolume) createCloneFromImage(ctx context.Context, parentVol *rbdVol
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
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 err != nil || errFlatten != nil {
|
||||||
if !errors.Is(errFlatten, ErrFlattenInProgress) {
|
if !errors.Is(errFlatten, ErrFlattenInProgress) {
|
||||||
// cleanup snapshot
|
// 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
|
// flatten clone
|
||||||
errFlatten = tempClone.flattenRbdImage(ctx, rv.conn.Creds, false, rbdHardMaxCloneDepth, rbdSoftMaxCloneDepth)
|
errFlatten = tempClone.flattenRbdImage(ctx, rv.conn.Creds, false, rbdHardMaxCloneDepth, rbdSoftMaxCloneDepth)
|
||||||
|
Loading…
Reference in New Issue
Block a user