Fixed-time wait for mount check after startup
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-10-03 19:14:57 +02:00
parent 2463ec3dc8
commit 6dc5992f81

20
main.go
View File

@@ -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
}
}