Skip to content

Commit

Permalink
refactor(CSI-250): add NFS mutually exclusive options for NFS
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyberezansky committed Sep 11, 2024
1 parent cdcf7fb commit 09cf230
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions charts/csi-wekafsplugin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pluginConfig:
snapshotVolumesWithoutQuotaEnforcement: false
mutuallyExclusiveMountOptions:
- "readcache,writecache,coherent,forcedirect"
- "sync,async"
mountProtocol:
# -- Use NFS transport for mounting Weka filesystems, off by default
useNfs: false
Expand Down
17 changes: 10 additions & 7 deletions pkg/wekafs/nfsmounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
)

type nfsMounter struct {
kMounter mount.Interface
debugPath string
selinuxSupport *bool
gc *innerPathVolGc
interfaceGroupName *string
clientGroupName string
kMounter mount.Interface
debugPath string
selinuxSupport *bool
gc *innerPathVolGc
interfaceGroupName *string
clientGroupName string
exclusiveMountOptions []mutuallyExclusiveMountOptionSet
}

func (m *nfsMounter) getGarbageCollector() *innerPathVolGc {
Expand All @@ -27,7 +28,7 @@ func newNfsMounter(driver *WekaFsDriver) *nfsMounter {
log.Debug().Msg("SELinux support is forced")
selinuxSupport = &[]bool{true}[0]
}
mounter := &nfsMounter{debugPath: driver.debugPath, selinuxSupport: selinuxSupport}
mounter := &nfsMounter{debugPath: driver.debugPath, selinuxSupport: selinuxSupport, exclusiveMountOptions: driver.config.mutuallyExclusiveOptions}
mounter.gc = initInnerPathVolumeGc(mounter)
mounter.schedulePeriodicMountGc()
mounter.interfaceGroupName = &driver.config.interfaceGroupName
Expand Down Expand Up @@ -65,6 +66,7 @@ func (m *nfsMounter) getSelinuxStatus(ctx context.Context) bool {
func (m *nfsMounter) mountWithOptions(ctx context.Context, fsName string, mountOptions MountOptions, apiClient *apiclient.ApiClient) (string, error, UnmountFunc) {
mountOptions.setSelinux(m.getSelinuxStatus(ctx), MountProtocolNfs)
mountOptions = mountOptions.AsNfs()
mountOptions.Merge(mountOptions, m.exclusiveMountOptions)
mountObj := m.NewMount(fsName, mountOptions)
mountErr := mountObj.incRef(ctx, apiClient)

Expand All @@ -87,6 +89,7 @@ func (m *nfsMounter) unmountWithOptions(ctx context.Context, fsName string, opti
opts := options
options.setSelinux(m.getSelinuxStatus(ctx), MountProtocolNfs)
options = options.AsNfs()
options.Merge(options, m.exclusiveMountOptions)
mnt := m.NewMount(fsName, options)

log.Ctx(ctx).Trace().Strs("mount_options", opts.Strings()).Str("filesystem", fsName).Msg("Received an unmount request")
Expand Down

0 comments on commit 09cf230

Please sign in to comment.