mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rbd: add EnsureImageCleanup to ensure image cleanup from trash
After moving moving image to trash, if `trash remove` step fails, then external-provisioner will issue subsequent requests, in which image will be absent in pool( will be in trash) and omap cleanup will be done with stale image left in trash with no `trash remove` step on it. To avoid this scenario list trash images and find corresponding id for given image name and add a task to flatten when we encounter a ErrImageNotFound. Fixes: #1728 Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
@ -776,8 +776,13 @@ func (cs *ControllerServer) checkErrAndUndoReserve(
|
||||
return &csi.DeleteVolumeResponse{}, nil
|
||||
}
|
||||
|
||||
// All errors other than ErrImageNotFound should return an error back to the caller
|
||||
if !errors.Is(err, ErrImageNotFound) {
|
||||
if errors.Is(err, ErrImageNotFound) {
|
||||
err = rbdVol.ensureImageCleanup(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
} else {
|
||||
// All errors other than ErrImageNotFound should return an error back to the caller
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
@ -924,8 +929,13 @@ func cleanupRBDImage(ctx context.Context,
|
||||
tempClone := rbdVol.generateTempClone()
|
||||
err = deleteImage(ctx, tempClone, cr)
|
||||
if err != nil {
|
||||
// return error if it is not ErrImageNotFound
|
||||
if !errors.Is(err, ErrImageNotFound) {
|
||||
if errors.Is(err, ErrImageNotFound) {
|
||||
err = tempClone.ensureImageCleanup(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
} else {
|
||||
// return error if it is not ErrImageNotFound
|
||||
log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v",
|
||||
tempClone, err)
|
||||
|
||||
|
Reference in New Issue
Block a user