Skip to content

Commit 3e783e9

Browse files
authored
chapi: busy or already mounted nfs mounts should be successfull (#153)
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]>
1 parent c4a8616 commit 3e783e9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

linux/mount.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,17 @@ func MountNFSShare(source string, targetPath string, options []string, nfsType s
589589
nfsType = defaultNFSType
590590
}
591591

592+
mountedSource := GetDeviceFromMountPoint(targetPath)
593+
if mountedSource != "" {
594+
// the source exists for the target path but differs from the expected mount, return error
595+
if mountedSource != source {
596+
err := fmt.Errorf("%s is already mounted at %s. Skipping mount for %s", mountedSource, source, targetPath)
597+
return err
598+
}
599+
// if mount point present with expected targetPath, return successful
600+
return nil
601+
}
602+
592603
args := []string{fmt.Sprintf("-t%s", nfsType), source, targetPath}
593604
optionArgs := []string{}
594605
if len(options) != 0 {

0 commit comments

Comments
 (0)