rbd: allow setting mkfsOptions in the StorageClass

Add `mkfsOptions` to the StorageClass and pass them to the `mkfs`
command while creating the filesystem on the RBD device.

Fixes: #374
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2023-02-23 18:07:43 +01:00
committed by mergify[bot]
parent 13cdb08e61
commit a4678200e5
3 changed files with 21 additions and 0 deletions

View File

@ -784,6 +784,15 @@ func (ns *NodeServer) mountVolumeToStagePath(
if existingFormat == "" && !staticVol && !readOnly {
args := mkfsDefaultArgs[fsType]
// if the VolumeContext contains "mkfsOptions", use those as args instead
volumeCtx := req.GetVolumeContext()
if volumeCtx != nil {
mkfsOptions := volumeCtx["mkfsOptions"]
if mkfsOptions != "" {
args = strings.Split(mkfsOptions, " ")
}
}
// add extra arguments depending on the filesystem
mkfs := "mkfs." + fsType
switch fsType {