Skip to content

Commit b394aca

Browse files
authored
chapi: provide option to specify nfs version type (#119)
* chapi: provide option to specify nfs version type * Problem: * Some flavors default to nfs4 and others to nfs4.1 causing mounts to fail if * server doesn't support 4.1 * Implementation: * Add nfsType option to mount * Testing: tested with multiple nfs mounts using csi * Review: gcostea, rkumar, sbyadarahalli Signed-off-by: Shiva Krishna, Merla <[email protected]>
1 parent 0799fec commit b394aca

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

chapi/chapidriver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Driver interface {
1818
DeleteDevice(device *model.Device) error
1919
OfflineDevice(device *model.Device) error
2020
MountDevice(device *model.Device, mountPoint string, mountOptions []string, fsOpts *model.FilesystemOpts) (*model.Mount, error) // Idempotent
21-
MountNFSVolume(source string, target string, mountOptions []string) error // Idempotent
21+
MountNFSVolume(source string, target string, mountOptions []string, nfsType string) error // Idempotent
2222
BindMount(mountPoint string, newMountPoint string, rbind bool) error // Idempotent
2323
BindUnmount(mountPoint string) error // Idempotent
2424
UnmountDevice(device *model.Device, mountPoint string) (*model.Mount, error) // Idempotent

chapi/chapidriver_fake.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,6 @@ func (driver *FakeDriver) ExpandDevice(targetPath string, volAccessType model.Vo
156156
}
157157

158158
// MountNFSVolume mounts NFS share onto given target path
159-
func (driver *FakeDriver) MountNFSVolume(source string, targetPath string, mountOptions []string) error {
159+
func (driver *FakeDriver) MountNFSVolume(source string, targetPath string, mountOptions []string, nfsType string) error {
160160
return nil
161161
}

chapi/chapidriver_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,11 @@ func (driver *LinuxDriver) GetMountsForDevice(device *model.Device) ([]*model.Mo
235235
return linux.GetMountPointsForDevices(devices)
236236
}
237237

238-
func (driver *LinuxDriver) MountNFSVolume(source string, targetPath string, mountOptions []string) error {
238+
func (driver *LinuxDriver) MountNFSVolume(source string, targetPath string, mountOptions []string, nfsType string) error {
239239
log.Tracef(">>>>> MountNFSVolume called with source %s target %s options %v: ", source, targetPath, mountOptions)
240240
defer log.Trace("<<<<< MountNFSVolume")
241241

242-
err := linux.MountNFSShare(source, targetPath, mountOptions)
242+
err := linux.MountNFSShare(source, targetPath, mountOptions, nfsType)
243243
if err != nil {
244244
return fmt.Errorf("Error mounting nfs share %s at %s, err %s", source, targetPath, err.Error())
245245
}

linux/mount.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const (
7575
fsext3command = "mkfs.ext3"
7676
fsext4command = "mkfs.ext4"
7777
fsbtrfscommand = "mkfs.btrfs"
78+
defaultNFSType = "nfs4"
7879
)
7980

8081
// HashMountID : get hash of the string
@@ -570,11 +571,16 @@ func MountDeviceWithFileSystem(devPath string, mountPoint string, options []stri
570571
return mount, nil
571572
}
572573

573-
func MountNFSShare(source string, targetPath string, options []string) error {
574-
log.Tracef(">>>>> MountNFSShare called with source %s target %s", source, targetPath)
574+
func MountNFSShare(source string, targetPath string, options []string, nfsType string) error {
575+
log.Tracef(">>>>> MountNFSShare called with source %s target %s type %s", source, targetPath, nfsType)
575576
defer log.Tracef("<<<<< MountNFSShare")
576577

577-
args := []string{source, targetPath}
578+
// default type as nfs4
579+
if nfsType == "" {
580+
nfsType = defaultNFSType
581+
}
582+
583+
args := []string{fmt.Sprintf("-t%s", nfsType), source, targetPath}
578584
optionArgs := []string{}
579585
if len(options) != 0 {
580586
optionArgs = append([]string{"-o"}, strings.Join(options, ","))

0 commit comments

Comments
 (0)