[ARVADOS] created: 1.1.4-520-g57fd9fa6b
Git user
git at public.curoverse.com
Wed Jun 27 09:17:47 EDT 2018
at 57fd9fa6bf0ee3062d7d38aceb7e97543791d241 (commit)
commit 57fd9fa6bf0ee3062d7d38aceb7e97543791d241
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Wed Jun 27 10:16:23 2018 -0300
13219: Checks for expired run time and cancel container if needed.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/sdk/go/arvados/container.go b/sdk/go/arvados/container.go
index 5398d9d74..1bdf08902 100644
--- a/sdk/go/arvados/container.go
+++ b/sdk/go/arvados/container.go
@@ -20,6 +20,7 @@ type Container struct {
OutputPath string `json:"output_path"`
Priority int `json:"priority"`
RuntimeConstraints RuntimeConstraints `json:"runtime_constraints"`
+ StartedAt time.Time `json:"started_at"`
State ContainerState `json:"state"`
SchedulingParameters SchedulingParameters `json:"scheduling_parameters"`
}
@@ -54,6 +55,7 @@ type RuntimeConstraints struct {
type SchedulingParameters struct {
Partitions []string `json:"partitions"`
Preemptible bool `json:"preemptible"`
+ MaxRunTime int `json:"max_run_time"`
}
// ContainerList is an arvados#containerList resource.
diff --git a/sdk/go/dispatch/dispatch.go b/sdk/go/dispatch/dispatch.go
index 3289c67b0..ca2dbc48d 100644
--- a/sdk/go/dispatch/dispatch.go
+++ b/sdk/go/dispatch/dispatch.go
@@ -195,6 +195,13 @@ func (d *Dispatcher) checkListForUpdates(containers []arvados.Container, todo ma
case Queued:
tracker.close()
case Locked, Running:
+ if c.SchedulingParameters.MaxRunTime > 0 {
+ maxRunTime := time.Duration(c.SchedulingParameters.MaxRunTime) * time.Second
+ if time.Since(c.StartedAt) >= maxRunTime {
+ // Time's up, schedule container for cancellation
+ c.Priority = 0
+ }
+ }
tracker.update(c)
case Cancelled, Complete:
tracker.close()
commit 9df6d2c2152b5b1968649c970664c4f69d9e92e8
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Tue Jun 26 14:12:03 2018 -0300
13219: Adds default max_run_time value with validation, documentation and tests.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/doc/_includes/_container_scheduling_parameters.liquid b/doc/_includes/_container_scheduling_parameters.liquid
index 6eee4e044..abbe6f4c0 100644
--- a/doc/_includes/_container_scheduling_parameters.liquid
+++ b/doc/_includes/_container_scheduling_parameters.liquid
@@ -11,3 +11,5 @@ Parameters to be passed to the container scheduler (e.g., SLURM) when running a
table(table table-bordered table-condensed).
|_. Key|_. Type|_. Description|_. Notes|
|partitions|array of strings|The names of one or more compute partitions that may run this container. If not provided, the system will choose where to run the container.|Optional.|
+|preemptible|boolean|If true, the dispatcher will ask for a preemptible cloud node instance (eg: AWS Spot Instance) to run this container.|Optional. Default is false.|
+|max_run_time|integer|Maximum running time (in seconds) that this container will be allowed to run before being cancelled.|Optional. Default is 0 (no limit).|
diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb
index 7ec9845bc..06bd4a590 100644
--- a/services/api/app/models/container.rb
+++ b/services/api/app/models/container.rb
@@ -364,7 +364,9 @@ class Container < ArvadosModel
self.mounts ||= {}
self.cwd ||= "."
self.priority ||= 0
- self.scheduling_parameters ||= {}
+ self.scheduling_parameters ||= {
+ max_run_time: 0,
+ }
end
def permission_to_create
diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index a0ebdbab0..d80bd0c67 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -173,7 +173,9 @@ class ContainerRequest < ArvadosModel
self.mounts ||= {}
self.cwd ||= "."
self.container_count_max ||= Rails.configuration.container_count_max
- self.scheduling_parameters ||= {}
+ self.scheduling_parameters ||= {
+ max_run_time: 0,
+ }
self.output_ttl ||= 0
self.priority ||= 0
end
@@ -239,6 +241,11 @@ class ContainerRequest < ArvadosModel
if !Rails.configuration.preemptible_instances and scheduling_parameters['preemptible']
errors.add :scheduling_parameters, "preemptible instances are not allowed"
end
+ if scheduling_parameters.include? 'max_run_time' and
+ (!scheduling_parameters['max_run_time'].is_a?(Integer) ||
+ scheduling_parameters['max_run_time'] < 0)
+ errors.add :scheduling_parameters, "max_run_time must be positive integer"
+ end
end
end
diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 26a0048eb..f266c096b 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -855,6 +855,11 @@ class ContainerRequestTest < ActiveSupport::TestCase
[{"partitions" => "fastcpu"}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
[{"partitions" => "fastcpu"}, ContainerRequest::Uncommitted],
[{"partitions" => ["fastcpu","vfastcpu"]}, ContainerRequest::Committed],
+ [{"max_run_time" => "one day"}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
+ [{"max_run_time" => "one day"}, ContainerRequest::Uncommitted],
+ [{"max_run_time" => -1}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
+ [{"max_run_time" => -1}, ContainerRequest::Uncommitted],
+ [{"max_run_time" => 86400}, ContainerRequest::Committed],
].each do |sp, state, expected|
test "create container request with scheduling_parameters #{sp} in state #{state} and verify #{expected}" do
common_attrs = {cwd: "test",
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list