[ARVADOS] updated: 1.1.4-281-gf7029ec

Git user git at public.curoverse.com
Tue May 22 13:50:30 EDT 2018


Summary of changes:
 services/api/app/models/container_request.rb     |  7 +++
 services/api/config/application.default.yml      |  5 ++
 services/api/test/unit/container_request_test.rb | 69 ++++++++++++++++++++++++
 3 files changed, 81 insertions(+)

       via  f7029eca4ddc301167078827a6bed2219dd282a6 (commit)
      from  9df819a55f00e893f2783c1e048a6d3c1cd391b2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit f7029eca4ddc301167078827a6bed2219dd282a6
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Tue May 22 14:49:44 2018 -0300

    7478: Preemptable instances scheduling parameter on API server
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index ac4415b..5c5a043 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -223,6 +223,13 @@ class ContainerRequest < ArvadosModel
             scheduling_parameters['partitions'].size)
             errors.add :scheduling_parameters, "partitions must be an array of strings"
       end
+      if !self.scheduling_parameters.include?('preemptable')
+        if !self.requesting_container_uuid.nil? and Rails.configuration.preemptable_instances
+          self.scheduling_parameters['preemptable'] = true
+        end
+      elsif scheduling_parameters['preemptable'] and self.requesting_container_uuid.nil?
+        errors.add :scheduling_parameters, "only child containers can be preemptable"
+      end
     end
   end
 
diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml
index a1c35f1..19b6f9b 100644
--- a/services/api/config/application.default.yml
+++ b/services/api/config/application.default.yml
@@ -289,6 +289,11 @@ common:
   ### Crunch, DNS & compute node management
   ###
 
+  # Preemptable instance support (e.g. AWS Spot Instances)
+  # When true, child containers will get created with the preemptable
+  # scheduling parameter parameter set.
+  preemptable_instances: false
+
   # Docker image to be used when none found in runtime_constraints of a job
   default_docker_image_for_jobs: false
 
diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 3483b87..5bca02a 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -758,6 +758,75 @@ class ContainerRequestTest < ActiveSupport::TestCase
   end
 
   [
+    [{"preemptable" => true}, nil, ActiveRecord::RecordInvalid],
+    [{"preemptable" => false}, nil, nil],
+    [{"preemptable" => true}, 'zzzzz-dz642-runningcontainr', nil],
+    [{"preemptable" => false}, 'zzzzz-dz642-runningcontainr', nil],
+  ].each do |sp, requesting_c, expected|
+    test "create container request with scheduling_parameters #{sp} with requesting_container_uuid=#{requesting_c} and verify #{expected}" do
+      common_attrs = {cwd: "test",
+                      priority: 1,
+                      command: ["echo", "hello"],
+                      output_path: "test",
+                      scheduling_parameters: sp,
+                      mounts: {"test" => {"kind" => "json"}}}
+
+      set_user_from_auth :active
+
+      if requesting_c
+        cr = with_container_auth(Container.find_by_uuid requesting_c) do
+          create_minimal_req!(common_attrs)
+        end
+        assert_not_nil cr.requesting_container_uuid
+      else
+        cr = create_minimal_req!(common_attrs)
+      end
+
+      cr.state = ContainerRequest::Committed
+      if !expected.nil?
+        assert_raises(expected) do
+          cr.save!
+        end
+      else
+        cr.save!
+        assert_equal sp, cr.scheduling_parameters
+      end
+    end
+  end
+
+  [
+    [true, 'zzzzz-dz642-runningcontainr', true],
+    [true, nil, nil],
+    [false, 'zzzzz-dz642-runningcontainr', nil],
+    [false, nil, nil],
+  ].each do |preemptable_conf, requesting_c, schedule_preemptable|
+    test "having Rails.configuration.preemptable_instances=#{preemptable_conf}, #{requesting_c.nil? ? 'non-':''}child CR should #{schedule_preemptable ? '':'not'} ask for preemptable instance by default" do
+      common_attrs = {cwd: "test",
+                      priority: 1,
+                      command: ["echo", "hello"],
+                      output_path: "test",
+                      mounts: {"test" => {"kind" => "json"}}}
+
+      Rails.configuration.preemptable_instances = preemptable_conf
+      set_user_from_auth :active
+
+      if requesting_c
+        cr = with_container_auth(Container.find_by_uuid requesting_c) do
+          create_minimal_req!(common_attrs)
+        end
+        assert_not_nil cr.requesting_container_uuid
+      else
+        cr = create_minimal_req!(common_attrs)
+      end
+
+      cr.state = ContainerRequest::Committed
+      cr.save!
+
+      assert_equal schedule_preemptable, cr.scheduling_parameters['preemptable']
+    end
+  end
+
+  [
     [{"partitions" => ["fastcpu","vfastcpu", 100]}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
     [{"partitions" => ["fastcpu","vfastcpu", 100]}, ContainerRequest::Uncommitted],
     [{"partitions" => "fastcpu"}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list