From 2deabcd2840ce06101c8646927f102ee1aeb947d Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 17 Aug 2020 13:38:57 +0530 Subject: [PATCH] rbd: allow readonly only for volume with contentsource It doesnot make sense to allow the creation of empty volumes which is going to be accessed with readonly mode, this commit allows the creation of volume which is having readonly capabilities only if the content source is set for the volume. Signed-off-by: Madhu Rajanna --- internal/rbd/controllerserver.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index cf9163124..08bae17fa 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -80,6 +80,13 @@ func (cs *ControllerServer) validateVolumeReq(ctx context.Context, req *csi.Crea if value, ok := options["volumeNamePrefix"]; ok && value == "" { return status.Error(codes.InvalidArgument, "empty volume name prefix to provision volume from") } + + // Allow readonly access mode for volume with content source + err := util.CheckReadOnlyManyIsSupported(req) + if err != nil { + return err + } + return nil }