mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
cleanup: add IsBlockMultiNode() helper
IsBlockMultiNode() is a new helper that takes a slice of VolumeCapability objects and checks if it includes multi-node access and/or block-mode support. This can then easily be used in other services that need checking for these particular capabilities, and preventing multi-node block-mode access. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
50d6ea825c
commit
30333378ef
@ -99,17 +99,8 @@ func (cs *ControllerServer) parseVolCreateRequest(
|
||||
req *csi.CreateVolumeRequest) (*rbdVolume, error) {
|
||||
// TODO (sbezverk) Last check for not exceeding total storage capacity
|
||||
|
||||
isMultiNode := false
|
||||
isBlock := false
|
||||
for _, capability := range req.VolumeCapabilities {
|
||||
// RO modes need to be handled independently (ie right now even if access mode is RO, they'll be RW upon attach)
|
||||
if capability.GetAccessMode().GetMode() == csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER {
|
||||
isMultiNode = true
|
||||
}
|
||||
if capability.GetBlock() != nil {
|
||||
isBlock = true
|
||||
}
|
||||
}
|
||||
// RO modes need to be handled independently (ie right now even if access mode is RO, they'll be RW upon attach)
|
||||
isBlock, isMultiNode := csicommon.IsBlockMultiNode(req.VolumeCapabilities)
|
||||
|
||||
// We want to fail early if the user is trying to create a RWX on a non-block type device
|
||||
if isMultiNode && !isBlock {
|
||||
|
Reference in New Issue
Block a user