mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 06:10:22 +00:00
cephfs: remove subvolume during clone
If any operations like Resize, Deleting snapshot fails, we need to remove both snapshot and the clone to avoid resource leak. closes: #4218 Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
2598300f66
commit
c25f572ae0
@ -68,11 +68,10 @@ func (s *subVolumeClient) CreateCloneFromSubvolume(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// if cloneErr is not nil we will delete the snapshot
|
|
||||||
var cloneErr error
|
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if cloneErr != nil {
|
// if any error occurs while cloning, resizing or deleting the snapshot
|
||||||
|
// fails then we need to delete the clone and snapshot.
|
||||||
|
if err != nil && !cerrors.IsCloneRetryError(err) {
|
||||||
if err = s.PurgeVolume(ctx, true); err != nil {
|
if err = s.PurgeVolume(ctx, true); err != nil {
|
||||||
log.ErrorLog(ctx, "failed to delete volume %s: %v", s.VolID, err)
|
log.ErrorLog(ctx, "failed to delete volume %s: %v", s.VolID, err)
|
||||||
}
|
}
|
||||||
@ -81,18 +80,19 @@ func (s *subVolumeClient) CreateCloneFromSubvolume(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
cloneErr = snapClient.CloneSnapshot(ctx, s.SubVolume)
|
err = snapClient.CloneSnapshot(ctx, s.SubVolume)
|
||||||
if cloneErr != nil {
|
if err != nil {
|
||||||
log.ErrorLog(ctx, "failed to clone snapshot %s %s to %s %v", parentvolOpt.VolID, snapshotID, s.VolID, cloneErr)
|
log.ErrorLog(ctx, "failed to clone snapshot %s %s to %s %v", parentvolOpt.VolID, snapshotID, s.VolID, err)
|
||||||
|
|
||||||
return cloneErr
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cloneState, cloneErr := s.GetCloneState(ctx)
|
var cloneState cephFSCloneState
|
||||||
if cloneErr != nil {
|
cloneState, err = s.GetCloneState(ctx)
|
||||||
log.ErrorLog(ctx, "failed to get clone state: %v", cloneErr)
|
if err != nil {
|
||||||
|
log.ErrorLog(ctx, "failed to get clone state: %v", err)
|
||||||
|
|
||||||
return cloneErr
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cloneState.ToError()
|
err = cloneState.ToError()
|
||||||
@ -157,7 +157,6 @@ func (s *subVolumeClient) CreateCloneFromSnapshot(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
cloneState, err := s.GetCloneState(ctx)
|
cloneState, err := s.GetCloneState(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorLog(ctx, "failed to get clone state: %v", err)
|
log.ErrorLog(ctx, "failed to get clone state: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user