diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index 41c6ed6a4..ad25382f9 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -362,6 +362,27 @@ func (cs *ControllerServer) repairExistingVolume(ctx context.Context, req *csi.C // rbdVol is a restore from snapshot, rbdSnap is passed case vcs.GetSnapshot() != nil: + // When restoring of a thick-provisioned volume was happening, + // the image should be marked as thick-provisioned, unless it + // was aborted in flight. In order to restart the + // thick-restoring, delete the volume and let the caller retry + // from the start. + if isThickProvisionRequest(req.GetParameters()) { + thick, err := rbdVol.isThickProvisioned() + if err != nil { + return nil, status.Errorf(codes.Aborted, "failed to verify thick-provisioned volume %q: %s", rbdVol, err) + } else if !thick { + err = deleteImage(ctx, rbdVol, cr) + if err != nil { + return nil, status.Errorf(codes.Aborted, "failed to remove partially cloned volume %q: %s", rbdVol, err) + } + err = undoVolReservation(ctx, rbdVol, cr) + if err != nil { + return nil, status.Errorf(codes.Aborted, "failed to remove volume %q from journal: %s", rbdVol, err) + } + return nil, status.Errorf(codes.Aborted, "restoring thick-provisioned volume %q has been interrupted, please retry", rbdVol) + } + } // restore from snapshot imploes rbdSnap != nil // check if image depth is reached limit and requires flatten err := checkFlatten(ctx, rbdVol, cr)