Skip to content

Commit

Permalink
chapi: busy or already mounted nfs mounts should be successfull (#153)
Browse files Browse the repository at this point in the history
Problem:
- just like regular pvc mounts, if the mounts for the volume already exist(
the previous commands times out) we treat the subsequent mount as success if the same
source and target are present. The same logic was missing for nfs mounts.

Signed-off-by: Raunak <[email protected]>
  • Loading branch information
raunakkumar authored Jun 7, 2021
1 parent c4a8616 commit 3e783e9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions linux/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,17 @@ func MountNFSShare(source string, targetPath string, options []string, nfsType s
nfsType = defaultNFSType
}

mountedSource := GetDeviceFromMountPoint(targetPath)
if mountedSource != "" {
// the source exists for the target path but differs from the expected mount, return error
if mountedSource != source {
err := fmt.Errorf("%s is already mounted at %s. Skipping mount for %s", mountedSource, source, targetPath)
return err
}
// if mount point present with expected targetPath, return successful
return nil
}

args := []string{fmt.Sprintf("-t%s", nfsType), source, targetPath}
optionArgs := []string{}
if len(options) != 0 {
Expand Down

0 comments on commit 3e783e9

Please sign in to comment.