# Default value for keep_cache_ram of a container's
# runtime_constraints. Note: this gets added to the RAM request
- # used to allocate a VM or submit an HPC job
+ # used to allocate a VM or submit an HPC job.
+ #
+ # If this is zero, container requests that don't specify RAM or
+ # disk cache size will use a disk cache, sized to the
+ # container's RAM requirement (but with minimum 2 GiB and
+ # maximum 32 GiB).
DefaultKeepCacheRAM: 0
- # Default value for keep_cache_disk of a container's
- # runtime_constraints. Note: this gets added to the disk
- # request used to allocate a VM or submit an HPC job
- DefaultKeepCacheDisk: 8589934592
-
# Number of times a container can be unlocked before being
# automatically cancelled.
MaxDispatchAttempts: 5
"Containers.CrunchRunArgumentsList": false,
"Containers.CrunchRunCommand": false,
"Containers.DefaultKeepCacheRAM": true,
- "Containers.DefaultKeepCacheDisk": true,
"Containers.DispatchPrivateKey": false,
"Containers.JobsAPI": true,
"Containers.JobsAPI.Enable": true,
rc['keep_cache_ram'] = Rails.configuration.Containers.DefaultKeepCacheRAM
end
if rc['keep_cache_disk'] == 0 and rc['keep_cache_ram'] == 0
- # Only set if keep_cache_ram isn't set.
- rc['keep_cache_disk'] = Rails.configuration.Containers.DefaultKeepCacheDisk
+ # If neither ram nor disk cache was specified and
+ # DefaultKeepCacheRAM==0, default to disk cache with size equal
+ # to RAM constraint (but at least 2 GiB and at most 32 GiB).
+ rc['keep_cache_disk'] = [[rc['ram'] || 0, 2 << 30].max, 32 << 30].min
end
rc
end
{"runtime_constraints" => {"vcpus" => 1}},
{"runtime_constraints" => {"vcpus" => 1, "ram" => nil}},
{"runtime_constraints" => {"vcpus" => 0, "ram" => 123}},
- {"runtime_constraints" => {"vcpus" => "1", "ram" => "123"}},
+ {"runtime_constraints" => {"vcpus" => "1", "ram" => -1}},
{"mounts" => {"FOO" => "BAR"}},
{"mounts" => {"FOO" => {}}},
{"mounts" => {"FOO" => {"kind" => "tmp", "capacity" => 42.222}}},
test "Container request commit" do
set_user_from_auth :active
- cr = create_minimal_req!(runtime_constraints: {"vcpus" => 2, "ram" => 30})
+ cr = create_minimal_req!(runtime_constraints: {"vcpus" => 2, "ram" => 300000000})
assert_nil cr.container_uuid
cr.reload
- assert ({"vcpus" => 2, "ram" => 30}.to_a - cr.runtime_constraints.to_a).empty?
+ assert_empty({"vcpus" => 2, "ram" => 300000000}.to_a - cr.runtime_constraints.to_a)
assert_equal 0, Rails.configuration.Containers.DefaultKeepCacheRAM
- assert_equal 8589934592, Rails.configuration.Containers.DefaultKeepCacheDisk
assert_not_nil cr.container_uuid
c = Container.find_by_uuid cr.container_uuid
assert_equal({}, c.environment)
assert_equal({"/out" => {"kind"=>"tmp", "capacity"=>1000000}}, c.mounts)
assert_equal "/out", c.output_path
- assert ({"keep_cache_disk"=>8589934592, "keep_cache_ram"=>0, "vcpus" => 2, "ram" => 30}.to_a - c.runtime_constraints.to_a).empty?
+ assert ({"keep_cache_disk" => 2<<30, "keep_cache_ram" => 0, "vcpus" => 2, "ram" => 300000000}.to_a - c.runtime_constraints.to_a).empty?
assert_operator 0, :<, c.priority
assert_raises(ActiveRecord::RecordInvalid) do