From eeec4471c5d89b0ce0fcbea5300814b479a6bbdb Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 21 Jun 2021 11:05:24 +0200 Subject: [PATCH] rbd: no need to create a snapshot on a thick-provisioned volume When cloning a volume from a (CSI) snapshot, we use DeepCopy() and do not need an RBD snapshot as source. Suggested-by: Madhu Rajanna Signed-off-by: Niels de Vos --- internal/rbd/controllerserver.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index ad25382f9..b977c4d49 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -1047,7 +1047,6 @@ func (cs *ControllerServer) doSnapshotClone(ctx context.Context, parentVol *rbdV // 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) @@ -1058,14 +1057,14 @@ func (cs *ControllerServer) doSnapshotClone(ctx context.Context, parentVol *rbdV 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 - rbdSnap.RbdImageName = cloneRbd.RbdImageName - util.ErrorLog(ctx, "failed to create snapshot %s: %v", rbdSnap, err) - return ready, cloneRbd, err + } else { + err = cloneRbd.createSnapshot(ctx, rbdSnap) + if err != nil { + // update rbd image name for logging + rbdSnap.RbdImageName = cloneRbd.RbdImageName + util.ErrorLog(ctx, "failed to create snapshot %s: %v", rbdSnap, err) + return ready, cloneRbd, err + } } err = cloneRbd.getImageID()