Verify mount appears as containers wrote to unmounted directories.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2023-06-02 00:22:03 +02:00
parent c7adbd3f5d
commit f6b91fd742

25
main.go
View File

@@ -24,6 +24,7 @@ import (
"os/user"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
@@ -275,13 +276,23 @@ func (d *ofsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
return &volume.MountResponse{}, fmt.Errorf("unexpected error mounting '%s' error: %s", r.Name, err.Error())
}
// The drawback of running the mount in the foreground is there is no way to tell if it failed
// to initially connect. So we just wait a fixed amount of time and check for process exit.
time.Sleep(1 * time.Second)
if cmd.ProcessState != nil {
// The process has exited so consider an error occured
log.WithFields(log.Fields{"name": r.Name, "exitStatus": cmd.ProcessState.ExitCode()}).Error("Volume mount failed")
return &volume.MountResponse{}, fmt.Errorf("unexpected error mounting '%s' exist status: %v", r.Name, cmd.ProcessState.ExitCode())
// 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 {
// Check for process exit
time.Sleep(100 * time.Millisecond)
if cmd.ProcessState != nil {
// The process has exited so consider an error occured
log.WithFields(log.Fields{"name": r.Name, "exitStatus": cmd.ProcessState.ExitCode()}).Error("Volume mount failed")
return &volume.MountResponse{}, fmt.Errorf("unexpected error mounting '%s' exist status: %v", r.Name, cmd.ProcessState.ExitCode())
}
// Check for mount
mount := exec.Command("df", "--output=fstype", v.Volume.Mountpoint)
if out, err := mount.CombinedOutput(); err == nil && strings.Index(string(out), "fuse.objectivefs") >= 0 {
break
}
}
log.WithFields(log.Fields{"name": r.Name}).Info("Volume mounted")