17816: Sort bind mounts on singularity command line
authorPeter Amstutz <peter.amstutz@curii.com>
Fri, 16 Jul 2021 15:00:57 +0000 (11:00 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Fri, 16 Jul 2021 15:00:57 +0000 (11:00 -0400)
Need to mount parent directories before we can mount things inside
them.

Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

lib/crunchrun/singularity.go

index 2a294cf03c4715c36e20230d5610eac5afbdbeaf..bcaff3bcc88300e51015f16a94751d20a39d5efe 100644 (file)
@@ -8,6 +8,7 @@ import (
        "io/ioutil"
        "os"
        "os/exec"
+       "sort"
        "syscall"
 
        "golang.org/x/net/context"
@@ -82,7 +83,13 @@ func (e *singularityExecutor) Start() error {
                false: "rw",
                true:  "ro",
        }
-       for path, mount := range e.spec.BindMounts {
+       var binds []string
+       for path, _ := range e.spec.BindMounts {
+               binds = append(binds, path)
+       }
+       sort.Strings(binds)
+       for _, path := range binds {
+               mount := e.spec.BindMounts[path]
                args = append(args, "--bind", mount.HostPath+":"+path+":"+readonlyflag[mount.ReadOnly])
        }
        args = append(args, e.imageFilename)