Merge pull request #456 from Madhu-1/rbd-mount-opt

support mountflags during nodepublish in rbd
This commit is contained in:
Humble Devassy Chirammal 2019-07-08 10:45:07 +05:30 committed by GitHub
commit 3dde768894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -34,3 +34,5 @@ parameters:
# uncomment the following to use rbd-nbd as mounter on supported nodes
# mounter: rbd-nbd
reclaimPolicy: Delete
mountOptions:
- discard

View File

@ -144,17 +144,15 @@ func (ns *NodeServer) mountVolume(req *csi.NodePublishVolumeRequest, devicePath
diskMounter := &mount.SafeFormatAndMount{Interface: ns.mounter, Exec: mount.NewOsExec()}
if isBlock {
options := []string{"bind"}
if err := diskMounter.Mount(devicePath, targetPath, fsType, options); err != nil {
mountFlags = append(mountFlags, "bind")
if err := diskMounter.Mount(devicePath, targetPath, fsType, mountFlags); err != nil {
return err
}
} else {
options := []string{}
if readOnly {
options = append(options, "ro")
mountFlags = append(mountFlags, "ro")
}
if err := diskMounter.FormatAndMount(devicePath, targetPath, fsType, options); err != nil {
if err := diskMounter.FormatAndMount(devicePath, targetPath, fsType, mountFlags); err != nil {
return err
}
}