[ARVADOS] created: 1.1.4-491-g29e80f471
Git user
git at public.curoverse.com
Wed Jun 20 15:18:00 EDT 2018
at 29e80f471f1d70d1d1eda43b05e0f2e059564509 (commit)
commit 29e80f471f1d70d1d1eda43b05e0f2e059564509
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Tue Jun 19 19:47:21 2018 -0300
7478: Fixes default preemptible parameter when submitting committed child CRs
The API server wasn't auto-assigning this scheduling parameter on
child container requests because the requesting_container_uuid field
was being assigned after the callback.
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 799aa430f..dbafb9ac5 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -29,7 +29,6 @@ class ContainerRequest < ArvadosModel
before_validation :fill_field_defaults, :if => :new_record?
before_validation :validate_runtime_constraints
before_validation :set_container
- before_validation :set_default_preemptible_scheduling_parameter
validates :command, :container_image, :output_path, :cwd, :presence => true
validates :output_ttl, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :priority, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 1000 }
@@ -38,7 +37,8 @@ class ContainerRequest < ArvadosModel
validate :check_update_whitelist
validate :secret_mounts_key_conflict
before_save :scrub_secret_mounts
- before_create :set_requesting_container_uuid
+ before_save :set_requesting_container_uuid
+ before_save :set_default_preemptible_scheduling_parameter
before_destroy :set_priority_zero
after_save :update_priority
after_save :finalize_if_needed
@@ -313,7 +313,7 @@ class ContainerRequest < ArvadosModel
end
def set_requesting_container_uuid
- return if !current_api_client_authorization
+ return if !current_api_client_authorization || !self.requesting_container_uuid.nil?
if (c = Container.where('auth_uuid=?', current_api_client_authorization.uuid).select([:uuid, :priority]).first)
self.requesting_container_uuid = c.uuid
self.priority = c.priority>0 ? 1 : 0
diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 8071e05ce..0a21e15ec 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -849,6 +849,25 @@ class ContainerRequestTest < ActiveSupport::TestCase
end
end
+ test "submit a Committed child CR with preemptible_instances active" do
+ attrs = {cwd: "test",
+ priority: 1,
+ state: ContainerRequest::Committed,
+ command: ["echo", "hello"],
+ output_path: "test",
+ mounts: {"test" => {"kind" => "json"}}}
+
+ Rails.configuration.preemptible_instances = true
+ set_user_from_auth :active
+
+ cr = with_container_auth(Container.find_by_uuid 'zzzzz-dz642-runningcontainr') do
+ create_minimal_req!(attrs)
+ end
+
+ assert_not_nil cr.requesting_container_uuid
+ assert_equal true, cr.scheduling_parameters['preemptible']
+ end
+
[
[{"partitions" => ["fastcpu","vfastcpu", 100]}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
[{"partitions" => ["fastcpu","vfastcpu", 100]}, ContainerRequest::Uncommitted],
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list