8017: RuntimeConstraints uses int64
[arvados.git] / services / crunch-dispatch-slurm / crunch-dispatch-slurm.go
index 07653b1de1668e404f9cd0ec1b086edae00951cd..8c3f5c99fc64b8c9d1d49021190ffc97000f4c71 100644 (file)
@@ -6,6 +6,7 @@ import (
        "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
        "io/ioutil"
        "log"
+       "math"
        "os"
        "os/exec"
        "os/signal"
@@ -107,10 +108,10 @@ func runQueuedContainers(pollInterval, priorityPollInterval int, crunchRunComman
 
 // Container data
 type Container struct {
-       UUID               string         `json:"uuid"`
-       State              string         `json:"state"`
-       Priority           int            `json:"priority"`
-       RuntimeConstraints map[string]int `json:"runtime_constraints"`
+       UUID               string           `json:"uuid"`
+       State              string           `json:"state"`
+       Priority           int              `json:"priority"`
+       RuntimeConstraints map[string]int64 `json:"runtime_constraints"`
 }
 
 // ContainerList is a list of the containers from api
@@ -140,10 +141,11 @@ func dispatchSlurm(priorityPollInterval int, crunchRunCommand, finishCommand str
 
 // sbatchCmd
 func sbatchFunc(container Container) *exec.Cmd {
+       memPerCPU := math.Ceil(float64(container.RuntimeConstraints["ram"]) / float64(container.RuntimeConstraints["vcpus"]*1048576))
        return exec.Command("sbatch", "--share", "--parsable",
                "--job-name="+container.UUID,
-               "--mem="+strconv.Itoa(container.RuntimeConstraints["ram"]),
-               "--cpus-per-task="+strconv.Itoa(container.RuntimeConstraints["vcpus"]))
+               "--mem-per-cpu="+strconv.Itoa(int(memPerCPU)),
+               "--cpus-per-task="+strconv.Itoa(int(container.RuntimeConstraints["vcpus"])))
 }
 
 var sbatchCmd = sbatchFunc