forked from Ivasoft/objectivefs-docker-volume
Wait for mount.objectivefs to initalize before mount tests to avoi triggering a bug
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:
22
main.go
22
main.go
@@ -378,9 +378,14 @@ 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() {
|
||||
log.WithFields(log.Fields{"name": r.Name}).Info(scanner.Text())
|
||||
text := scanner.Text()
|
||||
if strings.HasPrefix(text, "NOTE: objectivefs license check") {
|
||||
mountInitDone = true
|
||||
}
|
||||
log.WithFields(log.Fields{"name": r.Name}).Info(text)
|
||||
}
|
||||
cmd.Wait()
|
||||
log.WithFields(log.Fields{"name": r.Name}).Info("Completed mount process")
|
||||
@@ -406,8 +411,15 @@ func (d *ofsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
|
||||
}
|
||||
|
||||
// Check for mount
|
||||
if isObjfs, err := isObjectiveFsMount(mountPath); err == nil && isObjfs {
|
||||
break
|
||||
// BUG: mount.objectivefs has a bug when option "noocache" is used that prevents us from checking
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -814,10 +826,6 @@ func getMountedSnaphots(baseDir string, checkMount bool) (map[string]string, err
|
||||
}
|
||||
|
||||
func isObjectiveFsMount(path string) (bool, error) {
|
||||
// Warning: If objectivefs is mounted with "noocache" then during the mount call
|
||||
// the directory is in a transitioning state and all file system accesses end
|
||||
// with the error "Input/output error". Therefore we omit the last argument of the
|
||||
// df command that would contain the "path" value.
|
||||
mount := exec.Command("df", "--output=target", "-t", "fuse.objectivefs", path)
|
||||
if data, err := mount.CombinedOutput(); err == nil {
|
||||
scanner := bufio.NewScanner(strings.NewReader(string(data)))
|
||||
|
||||
Reference in New Issue
Block a user