From 2463ec3dc85de7fac345d64e798b4a62c2290d4a Mon Sep 17 00:00:00 2001 From: Roman Vanicek Date: Thu, 3 Oct 2024 18:06:16 +0200 Subject: [PATCH] Wait for mount.objectivefs to initalize before mount tests to avoi triggering a bug --- main.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 552a9c4..79070bb 100644 --- a/main.go +++ b/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)))