[ARVADOS] created: f1adedeba07502273d39084d4ff3645b30067579

Git user git at public.curoverse.com
Tue May 3 15:11:14 EDT 2016


        at  f1adedeba07502273d39084d4ff3645b30067579 (commit)


commit f1adedeba07502273d39084d4ff3645b30067579
Author: radhika <radhika at curoverse.com>
Date:   Tue May 3 15:09:54 2016 -0400

    8017: pass ram and vcpus runtime_constraints from Container to sbatch command.

diff --git a/services/api/test/fixtures/containers.yml b/services/api/test/fixtures/containers.yml
index 22004b4..aa7ad31 100644
--- a/services/api/test/fixtures/containers.yml
+++ b/services/api/test/fixtures/containers.yml
@@ -10,6 +10,9 @@ queued:
   output: test
   output_path: test
   command: ["echo", "hello"]
+  runtime_constraints:
+    ram: 12000000000
+    vcpus: 4
 
 completed:
   uuid: zzzzz-dz642-compltcontainer
@@ -23,3 +26,6 @@ completed:
   output: test
   output_path: test
   command: ["echo", "hello"]
+  runtime_constraints:
+    ram: 12000000000
+    vcpus: 4
diff --git a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
index 8fbc0fa..07653b1 100644
--- a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
+++ b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
@@ -9,6 +9,7 @@ import (
 	"os"
 	"os/exec"
 	"os/signal"
+	"strconv"
 	"sync"
 	"syscall"
 	"time"
@@ -106,9 +107,10 @@ func runQueuedContainers(pollInterval, priorityPollInterval int, crunchRunComman
 
 // Container data
 type Container struct {
-	UUID     string `json:"uuid"`
-	State    string `json:"state"`
-	Priority int    `json:"priority"`
+	UUID               string         `json:"uuid"`
+	State              string         `json:"state"`
+	Priority           int            `json:"priority"`
+	RuntimeConstraints map[string]int `json:"runtime_constraints"`
 }
 
 // ContainerList is a list of the containers from api
@@ -137,8 +139,11 @@ func dispatchSlurm(priorityPollInterval int, crunchRunCommand, finishCommand str
 }
 
 // sbatchCmd
-func sbatchFunc(uuid string) *exec.Cmd {
-	return exec.Command("sbatch", "--job-name="+uuid, "--share", "--parsable")
+func sbatchFunc(container Container) *exec.Cmd {
+	return exec.Command("sbatch", "--share", "--parsable",
+		"--job-name="+container.UUID,
+		"--mem="+strconv.Itoa(container.RuntimeConstraints["ram"]),
+		"--cpus-per-task="+strconv.Itoa(container.RuntimeConstraints["vcpus"]))
 }
 
 var sbatchCmd = sbatchFunc
@@ -170,7 +175,7 @@ func submit(container Container, crunchRunCommand string) (jobid string, submitE
 	}()
 
 	// Create the command and attach to stdin/stdout
-	cmd := sbatchCmd(container.UUID)
+	cmd := sbatchCmd(container)
 	stdinWriter, stdinerr := cmd.StdinPipe()
 	if stdinerr != nil {
 		submitErr = fmt.Errorf("Error creating stdin pipe %v: %q", container.UUID, stdinerr)
diff --git a/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go b/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go
index 7355cff..82675b2 100644
--- a/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go
+++ b/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go
@@ -4,12 +4,14 @@ import (
 	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
 	"git.curoverse.com/arvados.git/sdk/go/arvadostest"
 
+	"fmt"
 	"io/ioutil"
 	"log"
 	"net/http"
 	"net/http/httptest"
 	"os"
 	"os/exec"
+	"strconv"
 	"strings"
 	"syscall"
 	"testing"
@@ -68,12 +70,12 @@ func (s *TestSuite) Test_doMain(c *C) {
 	var striggerCmdLine []string
 
 	// Override sbatchCmd
-	defer func(orig func(string) *exec.Cmd) {
+	defer func(orig func(Container) *exec.Cmd) {
 		sbatchCmd = orig
 	}(sbatchCmd)
-	sbatchCmd = func(uuid string) *exec.Cmd {
-		sbatchCmdLine = sbatchFunc(uuid).Args
-		return exec.Command("echo", uuid)
+	sbatchCmd = func(container Container) *exec.Cmd {
+		sbatchCmdLine = sbatchFunc(container).Args
+		return exec.Command("echo", container.UUID)
 	}
 
 	// Override striggerCmd
@@ -111,7 +113,12 @@ func (s *TestSuite) Test_doMain(c *C) {
 	err = doMain()
 	c.Check(err, IsNil)
 
-	c.Check(sbatchCmdLine, DeepEquals, []string{"sbatch", "--job-name=zzzzz-dz642-queuedcontainer", "--share", "--parsable"})
+	sbatchCmdComps := []string{"sbatch", "--share", "--parsable",
+		fmt.Sprintf("--job-name=%s", containers.Items[0].UUID),
+		fmt.Sprintf("--mem=%s", strconv.Itoa(containers.Items[0].RuntimeConstraints["ram"])),
+		fmt.Sprintf("--cpus-per-task=%s", strconv.Itoa(containers.Items[0].RuntimeConstraints["vcpus"]))}
+	c.Check(sbatchCmdLine, DeepEquals, sbatchCmdComps)
+
 	c.Check(striggerCmdLine, DeepEquals, []string{"strigger", "--set", "--jobid=zzzzz-dz642-queuedcontainer\n", "--fini",
 		"--program=/usr/bin/crunch-finish-slurm.sh " + os.Getenv("ARVADOS_API_HOST") + " 4axaw8zxe0qm22wa6urpp5nskcne8z88cvbupv653y1njyi05h 1 zzzzz-dz642-queuedcontainer"})
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list