10231: update crunchrun to pass Container.RuntimeConstraints.KeepCacheRAM as file...
authorradhika <radhika@curoverse.com>
Tue, 25 Oct 2016 19:05:57 +0000 (15:05 -0400)
committerradhika <radhika@curoverse.com>
Tue, 25 Oct 2016 19:05:57 +0000 (15:05 -0400)
sdk/go/arvados/container.go
services/crunch-run/crunchrun.go
services/crunch-run/crunchrun_test.go

index e5050cb79c944673343878d559b75fd3e97807ae..6a76f1f396a32c89544f55030cb586ae413d0c0b 100644 (file)
@@ -30,10 +30,11 @@ type Mount struct {
 // RuntimeConstraints specify a container's compute resources (RAM,
 // CPU) and network connectivity.
 type RuntimeConstraints struct {
-       API       *bool
-       RAM       int      `json:"ram"`
-       VCPUs     int      `json:"vcpus"`
-       Partition []string `json:"partition"`
+       API          *bool
+       RAM          int      `json:"ram"`
+       VCPUs        int      `json:"vcpus"`
+       KeepCacheRAM int      `json:"keep_cache_ram"`
+       Partition    []string `json:"partition"`
 }
 
 // ContainerList is an arvados#containerList resource.
index d804c01cad16700bc2b9ca52e3ff561499328095..ab3a9f524e68d137bf2ba371e2f8ba6a34e0ae21 100644 (file)
@@ -357,6 +357,10 @@ func (runner *ContainerRunner) SetupMounts() (err error) {
        }
        arvMountCmd = append(arvMountCmd, runner.ArvMountPoint)
 
+       if runner.Container.RuntimeConstraints.KeepCacheRAM > 0 {
+               arvMountCmd = append(arvMountCmd, "--file-cache", fmt.Sprintf("%d", runner.Container.RuntimeConstraints.KeepCacheRAM))
+       }
+
        token, err := runner.ContainerToken()
        if err != nil {
                return fmt.Errorf("could not get container token: %s", err)
index 0ce658721eaf63675ff0e132eb6d59ffb3f00587..7ac71cc486a92baf91464764bba69bd3a38da674 100644 (file)
@@ -840,6 +840,28 @@ func (s *TestSuite) TestSetupMounts(c *C) {
                checkEmpty()
        }
 
+       {
+               i = 0
+               cr.Container.RuntimeConstraints.KeepCacheRAM = 512
+               cr.Container.Mounts = map[string]arvados.Mount{
+                       "/keepinp": {Kind: "collection", PortableDataHash: "59389a8f9ee9d399be35462a0f92541c+53"},
+                       "/keepout": {Kind: "collection", Writable: true},
+               }
+               cr.OutputPath = "/keepout"
+
+               os.MkdirAll(realTemp+"/keep1/by_id/59389a8f9ee9d399be35462a0f92541c+53", os.ModePerm)
+               os.MkdirAll(realTemp+"/keep1/tmp0", os.ModePerm)
+
+               err := cr.SetupMounts()
+               c.Check(err, IsNil)
+               c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other", "--read-write", "--mount-tmp", "tmp0", "--mount-by-pdh", "by_id", realTemp + "/keep1", "--file-cache", "512"})
+               sort.StringSlice(cr.Binds).Sort()
+               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/keep1/by_id/59389a8f9ee9d399be35462a0f92541c+53:/keepinp:ro",
+                       realTemp + "/keep1/tmp0:/keepout"})
+               cr.CleanupDirs()
+               checkEmpty()
+       }
+
        for _, test := range []struct {
                in  interface{}
                out string