Skip to content

Commit

Permalink
fix(CSI-213): convert mount options to NFS compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyberezansky committed Aug 4, 2024
1 parent bac9415 commit 91d7cef
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pkg/wekafs/mountoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,41 @@ func (opts MountOptions) setSelinux(selinuxSupport bool, mountProtocol string) {
}
}

func (opts MountOptions) AsNfs() MountOptions {
ret := NewMountOptionsFromString("hard,rdirplus")
for _, o := range opts.getOpts() {
switch o.option {
case "writecache":
ret.AddOption("async")
case "coherent":
ret.AddOption("sync")
case "forcedirect":
ret.AddOption("sync")
case "readcache":
ret.AddOption("noac")
case "dentry_max_age_positive":
ret.AddOption(fmt.Sprintf("acdirmax=%s", o.value))
ret.AddOption(fmt.Sprintf("acregmax=%s", o.value))
case "inode_bits":
continue
case "verbose":
continue
case "quiet":
continue
case "acl":
ret.AddOption("user_xattr")
ret.AddOption("acl")
case "obs_direct":
continue
case "sync_on_close":
ret.AddOption("sync")
default:
continue
}
}
return ret
}

func NewMountOptionsFromString(optsString string) MountOptions {
if optsString == "" {
return NewMountOptions([]string{})
Expand Down
1 change: 1 addition & 0 deletions pkg/wekafs/nfsmounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,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()
mountObj := m.NewMount(fsName, mountOptions)
mountErr := mountObj.incRef(ctx, apiClient)

Expand Down

0 comments on commit 91d7cef

Please sign in to comment.