Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Commit

Permalink
Add retry for mounting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Miao Luo committed Sep 26, 2017
1 parent 0ff535a commit 034b10d
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions client_plugin/drivers/vfile/vfile_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const (
internalVolumePrefix = "_vF_"
fsType = "cifs"
initError = "vFile volume driver is not fully initialized yet."
mountError = "exit status 255"
)

/* VolumeDriver - vFile plugin volume driver struct
Expand Down Expand Up @@ -586,15 +587,7 @@ func (d *VolumeDriver) mountVFileVolume(volName string, mountpoint string, volRe
}
mountArgs = append(mountArgs, "-o", strings.Join(options, ","))

_, addr, _, err := d.dockerOps.GetSwarmInfo()
if err != nil {
log.WithFields(
log.Fields{"volume name": volName,
"error": err,
}).Error("Failed to get IP address from docker swarm ")
return err
}
source := "//" + addr + "/" + dockerops.FileShareName
source := "//127.0.0.1/" + dockerops.FileShareName
mountArgs = append(mountArgs, source)
mountArgs = append(mountArgs, mountpoint)

Expand All @@ -603,14 +596,25 @@ func (d *VolumeDriver) mountVFileVolume(volName string, mountpoint string, volRe
"arguments": mountArgs,
}).Info("Mounting volume with options ")
command := exec.Command("mount", mountArgs...)
output, err := command.CombinedOutput()
if err != nil {
log.WithFields(
log.Fields{"volume name": volName,
"output": string(output),
"error": err,
}).Error("Mount failed: ")
return err

// host can be slow which results in host unreachable error during mount
// retry the mounting before error out
mountRetry := 5
for mountRetry > 0 {
output, err := command.CombinedOutput()
if err != nil {
mountRetry--
log.WithFields(
log.Fields{"volume name": volName,
"output": string(output),
"error": err,
}).Error("Mount failed: ")
if mountRetry == 0 || err.Error() != mountError {
return err
}
} else {
mountRetry = 0
}
}

return nil
Expand Down

0 comments on commit 034b10d

Please sign in to comment.