runtime_req, _ = get_feature(self, "http://arvados.org/cwl#RuntimeConstraints")
if runtime_req:
- logger.warn("RuntimeConstraints not yet supported by container API")
+ runtime_constraints["keep_cache_ram"] = runtime_req["keep_cache"]
partition_req, _ = get_feature(self, "http://arvados.org/cwl#PartitionRequirement")
if partition_req:
'runtime_constraints': {
'vcpus': 3,
'ram': 3145728000,
+ 'keep_cache_ram': 512,
'API': True,
'partition': ['blurb']
}, 'priority': 1,
// 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.
errors.add :runtime_constraints, "#{k} must be a positive integer"
end
end
+
+ if runtime_constraints.include? 'keep_cache_ram' and
+ (!runtime_constraints['keep_cache_ram'].is_a?(Integer) or
+ runtime_constraints['keep_cache_ram'] <= 0)
+ errors.add :runtime_constraints, "keep_cache_ram must be a positive integer"
+ elsif !runtime_constraints.include? 'keep_cache_ram'
+ runtime_constraints['keep_cache_ram'] = Rails.configuration.container_default_keep_cache_ram
+ end
end
end
# with the cancelled container.
container_count_max: 3
+ # Default value for keep_cache_ram of a container's runtime_constraints.
+ container_default_keep_cache_ram: 268435456
+
development:
force_ssl: false
cache_classes: false
command: ["echo", "hello"],
output_path: "test",
runtime_constraints: {"vcpus" => 4,
- "ram" => 12000000000},
+ "ram" => 12000000000,
+ "keep_cache_ram" => 268435456},
mounts: {"test" => {"kind" => "json"}}}
set_user_from_auth :active
cr1 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Committed,
assert_equal cr.container_uuid, cr3.container_uuid
assert_equal ContainerRequest::Final, cr3.state
end
+
+ [
+ [{"vcpus" => 1, "ram" => 123, "keep_cache_ram" => 100}, ContainerRequest::Committed, 100],
+ [{"vcpus" => 1, "ram" => 123}, ContainerRequest::Uncommitted],
+ [{"vcpus" => 1, "ram" => 123}, ContainerRequest::Committed],
+ [{"vcpus" => 1, "ram" => 123, "keep_cache_ram" => -1}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
+ [{"vcpus" => 1, "ram" => 123, "keep_cache_ram" => '123'}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
+ ].each do |rc, state, expected|
+ test "create container request with #{rc} in state #{state} and verify keep_cache_ram #{expected}" do
+ common_attrs = {cwd: "test",
+ priority: 1,
+ command: ["echo", "hello"],
+ output_path: "test",
+ runtime_constraints: rc,
+ mounts: {"test" => {"kind" => "json"}}}
+ set_user_from_auth :active
+
+ if expected == ActiveRecord::RecordInvalid
+ assert_raises(ActiveRecord::RecordInvalid) do
+ create_minimal_req!(common_attrs.merge({state: state}))
+ end
+ else
+ cr = create_minimal_req!(common_attrs.merge({state: state}))
+ expected = Rails.configuration.container_default_keep_cache_ram if state == ContainerRequest::Committed and expected.nil?
+ assert_equal expected, cr.runtime_constraints['keep_cache_ram']
+ end
+ end
+ end
end
}
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)
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