mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
cleanup: add cleanup helper for incorrect thick volume
added a new helper function called cleanupThickClone to cleanup the snapshot and clone if the thick provisioning is not fully completed. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
ca29328554
commit
22365ab77f
@ -403,18 +403,7 @@ func (cs *ControllerServer) repairExistingVolume(ctx context.Context, req *csi.C
|
|||||||
rbdVol,
|
rbdVol,
|
||||||
err)
|
err)
|
||||||
} else if !thick {
|
} else if !thick {
|
||||||
err = cleanUpSnapshot(ctx, parentVol, rbdSnap, rbdVol, cr)
|
return nil, cleanupThickClone(ctx, parentVol, rbdVol, rbdSnap, cr)
|
||||||
if err != nil {
|
|
||||||
return nil, status.Errorf(codes.Internal, "failed to remove partially cloned volume %q: %s", rbdVol, err)
|
|
||||||
}
|
|
||||||
err = undoVolReservation(ctx, rbdVol, cr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, status.Errorf(codes.Internal, "failed to remove volume %q from journal: %s", rbdVol, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, status.Errorf(
|
|
||||||
codes.Internal,
|
|
||||||
"cloning thick-provisioned volume %q has been interrupted, please retry", rbdVol)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,6 +411,26 @@ func (cs *ControllerServer) repairExistingVolume(ctx context.Context, req *csi.C
|
|||||||
return buildCreateVolumeResponse(req, rbdVol), nil
|
return buildCreateVolumeResponse(req, rbdVol), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cleanupThickClone will delete the snapshot and volume and undo the reservation.
|
||||||
|
func cleanupThickClone(ctx context.Context,
|
||||||
|
rbdVol,
|
||||||
|
parentVol *rbdVolume,
|
||||||
|
rbdSnap *rbdSnapshot,
|
||||||
|
cr *util.Credentials) error {
|
||||||
|
err := cleanUpSnapshot(ctx, parentVol, rbdSnap, rbdVol, cr)
|
||||||
|
if err != nil {
|
||||||
|
return status.Errorf(codes.Internal, "failed to remove partially cloned volume %q: %s", rbdVol, err)
|
||||||
|
}
|
||||||
|
err = undoVolReservation(ctx, rbdVol, cr)
|
||||||
|
if err != nil {
|
||||||
|
return status.Errorf(codes.Internal, "failed to remove volume %q from journal: %s", rbdVol, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return status.Errorf(
|
||||||
|
codes.Internal,
|
||||||
|
"cloning thick-provisioned volume %q has been interrupted, please retry", rbdVol)
|
||||||
|
}
|
||||||
|
|
||||||
// check snapshots on the rbd image, as we have limit from krbd that an image
|
// check snapshots on the rbd image, as we have limit from krbd that an image
|
||||||
// cannot have more than 510 snapshot at a given point of time. If the
|
// cannot have more than 510 snapshot at a given point of time. If the
|
||||||
// snapshots are more than the `maxSnapshotsOnImage` Add a task to flatten all
|
// snapshots are more than the `maxSnapshotsOnImage` Add a task to flatten all
|
||||||
|
Loading…
Reference in New Issue
Block a user