From e1b5c53760e657b192b3980baf90db01391bd437 Mon Sep 17 00:00:00 2001 From: Prateek Pandey Date: Thu, 6 Aug 2020 11:20:35 +0530 Subject: [PATCH] fix(create): validate create volume request access mode (#109) Commits adds the validation to validate the create volume request access mode to validate and support only single node writer i.e. `ReadWriteOnce` accessmode and failed for other unsupported modes, like `ReadWriteMany` Signed-off-by: prateekpandey14 --- ci/ci-test.sh | 4 +--- pkg/driver/controller_utils.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ci/ci-test.sh b/ci/ci-test.sh index 7a860384d..9dca7685a 100755 --- a/ci/ci-test.sh +++ b/ci/ci-test.sh @@ -31,9 +31,7 @@ DST_PATH="$GOPATH/src/github.com/openebs" # Minikube is already running kubectl apply -f $CSTOR_RBAC kubectl apply -f $NDM_OPERATOR -kubectl apply -f $VOL_CRD -kubectl apply -f $CSPC_CRD -kubectl apply -f $CSPI_CRD +kubectl apply -f $ALL_CRD kubectl apply -f $CSTOR_OPERATOR kubectl apply -f $CSI_OPERATOR kubectl apply -f $SNAPSHOT_CLASS diff --git a/pkg/driver/controller_utils.go b/pkg/driver/controller_utils.go index 4d93ef215..36ad31f8a 100644 --- a/pkg/driver/controller_utils.go +++ b/pkg/driver/controller_utils.go @@ -150,6 +150,16 @@ func (cs *controller) validateVolumeCreateReq(req *csi.CreateVolumeRequest) erro ) } } + if mode := volcap.GetAccessMode(); mode != nil { + modeName := csi.VolumeCapability_AccessMode_Mode_name[int32(mode.GetMode())] + // we only support SINGLE_NODE_WRITER + if mode.GetMode() != csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER { + return status.Errorf(codes.InvalidArgument, + "only SINGLE_NODE_WRITER supported, unsupported access mode requested: %s", + modeName, + ) + } + } } return nil }