forked from Ivasoft/objectivefs-docker-volume
Fixed-time wait for mount check after startup
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
20
main.go
20
main.go
@@ -378,14 +378,9 @@ func (d *ofsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
|
||||
//"env": v.env, // for security reasons disabled
|
||||
}).Info("Mount ObjectiveFS Volume")
|
||||
scanner := bufio.NewScanner(cmdReader)
|
||||
mountInitDone := false
|
||||
go func() {
|
||||
for scanner.Scan() {
|
||||
text := scanner.Text()
|
||||
if strings.HasPrefix(text, "NOTE: objectivefs license check") {
|
||||
mountInitDone = true
|
||||
}
|
||||
log.WithFields(log.Fields{"name": r.Name}).Info(text)
|
||||
log.WithFields(log.Fields{"name": r.Name}).Info(scanner.Text())
|
||||
}
|
||||
cmd.Wait()
|
||||
log.WithFields(log.Fields{"name": r.Name}).Info("Completed mount process")
|
||||
@@ -401,7 +396,7 @@ func (d *ofsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
|
||||
// The drawback of running the mount in the foreground is there is no easy way to tell if it failed
|
||||
// to initially connect. So we just wait a fixed amount of time and check for process exit or mount
|
||||
// success.
|
||||
for i := 1; ; i++ {
|
||||
for i := 0; ; i++ {
|
||||
// Check for process exit
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if cmd.ProcessState != nil {
|
||||
@@ -415,11 +410,12 @@ func (d *ofsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
|
||||
// the mount point is properly initialized. If we check too early then something breaks in the
|
||||
// mount.objectivefs process and the mount forever stays in startup state returning "Input/output error"
|
||||
// for any filesystem interaction from us or other tools.
|
||||
// HACK: Due to the bug we listen to a well-known stdout text after which it is safe to check the mount point
|
||||
if mountInitDone {
|
||||
if isObjfs, err := isObjectiveFsMount(mountPath); err == nil && isObjfs {
|
||||
break
|
||||
}
|
||||
// HACK: Due to the bug we just wait a safe interval
|
||||
if i == 0 {
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
}
|
||||
if isObjfs, err := isObjectiveFsMount(mountPath); err == nil && isObjfs {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user