rbd: use helper functions from csi-common for VolumeCapability checking

The internal/csi-common package offers helper functions like
`IsReaderOnly()` and `IsBlockMultiNode()`. These should be used instead
of checking the VolumeCapability that is passed in a request in
different places.

This also suggested that adding the "ro" mount option in
`NodeServer.mountVolumeToStagePath()` is not appropriate, as the
csi-common helper `ConstructMountOptions()` can take care of that
already too.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2025-04-24 17:08:38 +02:00
committed by mergify[bot]
parent 34be059dd5
commit ea7be34396
2 changed files with 14 additions and 22 deletions

View File

@ -93,6 +93,14 @@ func ConstructMountOptions(mountOptions []string, volCap *csi.VolumeCapability)
}
}
// add "ro" in case the capabilities indicate READER_ONLY
rOnly := "ro"
if IsReaderOnly([]*csi.VolumeCapability{volCap}) {
if !MountOptionContains(mountOptions, rOnly) {
mountOptions = append(mountOptions, rOnly)
}
}
return mountOptions
}