From d293d91c07b9d4489b99043351ee10bec8be5819 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 12 Jan 2022 14:27:05 +0530 Subject: [PATCH] rbd: disallow creating small size volume from volume as per the CSI standard the size is optional parameter, as we are allowing the clone to a bigger size today we need to block the clone to a smaller size as its a have side effects like data corruption etc. Note:- Even though this check is present in kubernetes sidecar as CSI is CO independent adding the check here. updates: #2718 Signed-off-by: Madhu Rajanna --- internal/rbd/controllerserver.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index d7ad52950..b90398d29 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -231,6 +231,11 @@ func checkValidCreateVolumeRequest(rbdVol, parentVol *rbdVolume, rbdSnap *rbdSna if err != nil { return status.Errorf(codes.InvalidArgument, "cannot clone from volume %s: %s", parentVol, err.Error()) } + + err = parentVol.isCompabitableClone(&rbdVol.rbdImage) + if err != nil { + return status.Errorf(codes.InvalidArgument, "cannot clone from volume %s: %s", parentVol, err.Error()) + } } return nil