13063: Use upstream azure-sdk-for-go.
[arvados.git] / services / crunch-dispatch-slurm / squeue.go
index 819c2d2510f992ab75c18249d8b46d6c13828d6d..adb620ea8d34778f9d3c4d32edd42f518867b5a4 100644 (file)
@@ -8,7 +8,6 @@ import (
        "bytes"
        "fmt"
        "log"
-       "os/exec"
        "strings"
        "sync"
        "time"
@@ -23,18 +22,13 @@ type jobPriority struct {
 // command 'squeue'.
 type SqueueChecker struct {
        Period    time.Duration
+       Slurm     Slurm
        uuids     map[string]jobPriority
        startOnce sync.Once
        done      chan struct{}
        sync.Cond
 }
 
-func squeueFunc() *exec.Cmd {
-       return exec.Command("squeue", "--all", "--format=%j %y %Q")
-}
-
-var squeueCmd = squeueFunc
-
 // HasUUID checks if a given container UUID is in the slurm queue.
 // This does not run squeue directly, but instead blocks until woken
 // up by next successful update of squeue.
@@ -84,7 +78,7 @@ func (sqc *SqueueChecker) check() {
        sqc.L.Lock()
        defer sqc.L.Unlock()
 
-       cmd := squeueCmd()
+       cmd := sqc.Slurm.QueueCommand([]string{"--all", "--format=%j %y %Q"})
        stdout, stderr := &bytes.Buffer{}, &bytes.Buffer{}
        cmd.Stdout, cmd.Stderr = stdout, stderr
        if err := cmd.Run(); err != nil {