[ARVADOS] updated: f820c0ee9a10931fc80c5025a5c92bbd1395cf08

git at public.curoverse.com git at public.curoverse.com
Thu May 7 14:39:07 EDT 2015


Summary of changes:
 services/api/app/models/job.rb              |  6 +++++-
 services/api/config/application.default.yml |  3 +++
 services/api/test/unit/job_test.rb          | 20 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

       via  f820c0ee9a10931fc80c5025a5c92bbd1395cf08 (commit)
      from  fde21d34d011af2123668983c559632221390fd4 (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 f820c0ee9a10931fc80c5025a5c92bbd1395cf08
Author: Radhika Chippada <radhika at curoverse.com>
Date:   Thu May 7 14:17:55 2015 -0400

    3454: use configured default docker image when none found in a job's runtime_constraints.

diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb
index 0923a6f..6c24293 100644
--- a/services/api/app/models/job.rb
+++ b/services/api/app/models/job.rb
@@ -11,8 +11,8 @@ class Job < ArvadosModel
   before_validation :set_priority
   before_validation :update_state_from_old_state_attrs
   validate :ensure_script_version_is_commit
-  validate :find_arvados_sdk_version
   validate :find_docker_image_locator
+  validate :find_arvados_sdk_version
   validate :validate_status
   validate :validate_state_change
   validate :ensure_no_collection_uuids_in_script_params
@@ -205,6 +205,10 @@ class Job < ArvadosModel
   end
 
   def find_docker_image_locator
+    runtime_constraints['docker_image'] =
+        Rails.configuration.default_docker_image_for_jobs if ((runtime_constraints.is_a? Hash) and
+                                                              (runtime_constraints['docker_image']).nil? and
+                                                              Rails.configuration.default_docker_image_for_jobs)
     resolve_runtime_constraint("docker_image",
                                :docker_image_locator) do |image_search|
       image_tag = runtime_constraints['docker_image_tag']
diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml
index e5c00c5..d46c397 100644
--- a/services/api/config/application.default.yml
+++ b/services/api/config/application.default.yml
@@ -311,3 +311,6 @@ common:
   # won't be strictly enforced until those nodes with higher slot numbers
   # go down.
   max_compute_nodes: 64
+
+  # 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/job_test.rb b/services/api/test/unit/job_test.rb
index 6414889..f16c8b2 100644
--- a/services/api/test/unit/job_test.rb
+++ b/services/api/test/unit/job_test.rb
@@ -78,6 +78,26 @@ class JobTest < ActiveSupport::TestCase
     assert(job.invalid?, "Job with bad Docker tag valid")
   end
 
+  [
+    false,
+    true
+  ].each do |use_config|
+    test "Job with no Docker image uses default docker image when configuration is set #{use_config}" do
+      default_docker_image = collections(:docker_image)[:portable_data_hash]
+      Rails.configuration.default_docker_image_for_jobs = default_docker_image if use_config
+
+      job = Job.new job_attrs
+      assert job.valid?, job.errors.full_messages.to_s
+
+      if use_config
+        refute_nil job.docker_image_locator
+        assert_equal default_docker_image, job.docker_image_locator
+      else
+        assert_nil job.docker_image_locator
+      end
+    end
+  end
+
   test "create a job with a disambiguated script_version branch name" do
     job = Job.
       new(script: "testscript",

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list