diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index 4f9d535ac..deab669cd 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -895,6 +895,30 @@ func cloneFromSnapshot(ctx context.Context, rbdVol *rbdVolume, rbdSnap *rbdSnaps } } + // The clone image created during CreateSnapshot has to be marked as thick. + // As snapshot and volume both are independent we cannot depend on the + // parent volume of the clone to check thick provision during CreateVolume + // from snapshot operation because the parent volume can be deleted anytime + // after snapshot is created. + // TODO: copy thick provision config + thick, err := rbdVol.isThickProvisioned() + if err != nil { + return nil, status.Errorf(codes.Internal, "failed checking thick-provisioning of %q: %s", rbdVol, err) + } + + if thick { + // check the thick metadata is already set on the clone image. + thick, err = vol.isThickProvisioned() + if err != nil { + return nil, status.Errorf(codes.Internal, "failed checking thick-provisioning of %q: %s", vol, err) + } + if !thick { + err = vol.setThickProvisioned() + if err != nil { + return nil, status.Errorf(codes.Internal, "failed mark %q thick-provisioned: %s", vol, err) + } + } + } // if flattening is not needed, the snapshot is ready for use readyToUse := true @@ -986,6 +1010,24 @@ func (cs *ControllerServer) doSnapshotClone(ctx context.Context, parentVol *rbdV } } + // The clone image created during CreateSnapshot has to be marked as thick. + // As snapshot and volume both are independent we cannot depend on the + // parent volume of the clone to check thick provision during CreateVolume + // from snapshot operation because the parent volume can be deleted anytime + // after snapshot is created. + // TODO: copy thick provision config + thick, err := parentVol.isThickProvisioned() + if err != nil { + return ready, nil, status.Errorf(codes.Internal, "failed checking thick-provisioning of %q: %s", parentVol, err) + } + + if thick { + err = cloneRbd.setThickProvisioned() + if err != nil { + return ready, nil, status.Errorf(codes.Internal, "failed mark %q thick-provisioned: %s", cloneRbd, err) + } + } + err = cloneRbd.createSnapshot(ctx, rbdSnap) if err != nil { // update rbd image name for logging