[ARVADOS] created: 1.1.1-265-g0800af4

Git user git at public.curoverse.com
Fri Dec 15 16:45:42 EST 2017


        at  0800af4737546541d13dba3f6b6d42937936b6de (commit)


commit 0800af4737546541d13dba3f6b6d42937936b6de
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Fri Dec 15 16:35:38 2017 -0500

    12821: Write sbatch script in a tempfile instead of stdin.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
index 3d094c7..7331ef1 100644
--- a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
+++ b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
@@ -11,6 +11,8 @@ import (
 	"context"
 	"flag"
 	"fmt"
+	"io"
+	"io/ioutil"
 	"log"
 	"math"
 	"os"
@@ -220,9 +222,22 @@ var scontrolCmd = scontrolFunc
 func submit(dispatcher *dispatch.Dispatcher, container arvados.Container, crunchRunCommand []string) error {
 	cmd := sbatchCmd(container)
 
-	// Send a tiny script on stdin to execute the crunch-run
-	// command (slurm requires this to be a #! script)
-	cmd.Stdin = strings.NewReader(execScript(append(crunchRunCommand, container.UUID)))
+	// Save a shell script in a temp file. Slurm can accept the
+	// script on stdin, but this seems to have race bugs.
+	tmpfile, err := ioutil.TempFile("", "crunch-dispatch-slurm-sbatch-")
+	if err != nil {
+		return err
+	}
+	defer os.Remove(tmpfile.Name())
+	err = os.Chmod(tmpfile.Name(), 0700)
+	if err != nil {
+		return err
+	}
+	_, err = io.WriteString(tmpfile, execScript(append(crunchRunCommand, container.UUID)))
+	if err != nil {
+		return err
+	}
+	cmd.Args = append(cmd.Args, tmpfile.Name())
 
 	var stdout, stderr bytes.Buffer
 	cmd.Stdout = &stdout
@@ -233,7 +248,7 @@ func submit(dispatcher *dispatch.Dispatcher, container arvados.Container, crunch
 	defer sqCheck.L.Unlock()
 
 	log.Printf("exec sbatch %+q", cmd.Args)
-	err := cmd.Run()
+	err = cmd.Run()
 
 	switch err.(type) {
 	case nil:

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list