Skip to content

Commit cb23f71

Browse files
author
钱海波
committed
rbd: Allow provision of RBD with multiple access modes
If both ROX and RWO specified, RBD should be able to provision
1 parent a07260f commit cb23f71

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/util/validate.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,16 @@ func ValidateNodeUnpublishVolumeRequest(req *csi.NodeUnpublishVolumeRequest) err
8282
// CheckReadOnlyManyIsSupported checks the request is to create ReadOnlyMany
8383
// volume is from source as empty ReadOnlyMany is not supported.
8484
func CheckReadOnlyManyIsSupported(req *csi.CreateVolumeRequest) error {
85+
writable := false
8586
for _, capability := range req.GetVolumeCapabilities() {
8687
if m := capability.GetAccessMode().Mode; m == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY || m == csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY {
87-
if req.GetVolumeContentSource() == nil {
88-
return status.Error(codes.InvalidArgument, "readOnly accessMode is supported only with content source")
89-
}
88+
// do nothing
89+
} else {
90+
writable = true
9091
}
9192
}
93+
if ! writable && req.GetVolumeContentSource() == nil {
94+
return status.Error(codes.InvalidArgument, "readOnly accessMode is supported only with content source")
95+
}
9296
return nil
9397
}

0 commit comments

Comments
 (0)