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 <madhupr007@gmail.com>
(cherry picked from commit 2deabcd284)
This commit is contained in:
Madhu Rajanna 2020-08-17 13:38:57 +05:30 committed by mergify[bot]
parent c9601189ef
commit 5a7e188bb4

View File

@ -80,6 +80,13 @@ func (cs *ControllerServer) validateVolumeReq(ctx context.Context, req *csi.Crea
if value, ok := options["volumeNamePrefix"]; ok && value == "" { if value, ok := options["volumeNamePrefix"]; ok && value == "" {
return status.Error(codes.InvalidArgument, "empty volume name prefix to provision volume from") 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 return nil
} }