From df2680c50bc4e157b2f4f88dcd70ef3bde3e63d9 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 3 Jul 2019 17:15:23 +0530 Subject: [PATCH] support mountflags during nodepublish in rbd Fixes: #292 Signed-off-by: Madhu Rajanna --- examples/rbd/storageclass.yaml | 2 ++ pkg/rbd/nodeserver.go | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/rbd/storageclass.yaml b/examples/rbd/storageclass.yaml index 6e6c7e1be..c87f45348 100644 --- a/examples/rbd/storageclass.yaml +++ b/examples/rbd/storageclass.yaml @@ -34,3 +34,5 @@ parameters: # uncomment the following to use rbd-nbd as mounter on supported nodes # mounter: rbd-nbd reclaimPolicy: Delete +mountOptions: + - discard diff --git a/pkg/rbd/nodeserver.go b/pkg/rbd/nodeserver.go index 08a18d465..9099cd588 100644 --- a/pkg/rbd/nodeserver.go +++ b/pkg/rbd/nodeserver.go @@ -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 } }