[ARVADOS] updated: 2.1.0-227-g22895df84

Git user git at public.arvados.org
Wed Dec 30 21:02:39 UTC 2020


Summary of changes:
 services/api/app/models/container_request.rb           | 18 ++++++++++++++++--
 .../arvados/v1/container_requests_controller_test.rb   |  4 ++--
 2 files changed, 18 insertions(+), 4 deletions(-)

       via  22895df84dadaa0c2101443f765a3436b0282643 (commit)
      from  cd1329fbada00e83578725a77d1b59433061c655 (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 22895df84dadaa0c2101443f765a3436b0282643
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Wed Dec 30 18:02:20 2020 -0300

    17014: Fixes functional tests.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index 7012c1c32..51fda5469 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -31,6 +31,7 @@ class ContainerRequest < ArvadosModel
   serialize :scheduling_parameters, Hash
 
   before_validation :fill_field_defaults, :if => :new_record?
+  before_validation :forget_innocuous_serialized_fields_updates, on: :update
   before_validation :validate_runtime_constraints
   before_validation :set_default_preemptible_scheduling_parameter
   before_validation :set_container
@@ -344,6 +345,19 @@ class ContainerRequest < ArvadosModel
     end
   end
 
+  # Updates to serialized fields are all-or-nothing. Here we avoid making
+  # unnecessary updates.
+  def forget_innocuous_serialized_fields_updates
+    forgettable_attrs = []
+    if (runtime_constraints.to_a - runtime_constraints_was.to_a).empty?
+      forgettable_attrs.append('runtime_constraints')
+    end
+    if (scheduling_parameters.to_a - scheduling_parameters_was.to_a).empty?
+      forgettable_attrs.append('scheduling_parameters')
+    end
+    self.clear_attribute_changes(forgettable_attrs) if !forgettable_attrs.empty?
+  end
+
   def validate_runtime_constraints
     case self.state
     when Committed
@@ -469,12 +483,12 @@ class ContainerRequest < ArvadosModel
     # see https://dev.arvados.org/issues/17014#note-28 for details
 
     AttrsRuntimeConstraintsDefaults.each do |key, value|
-      if !attributes["runtime_constraints"].key?(key)
+      if attributes["runtime_constraints"] && !attributes["runtime_constraints"].key?(key)
         attributes["runtime_constraints"][key] = value
       end
     end
     AttrsSchedulingParametersDefaults.each do |key, value|
-      if !attributes["scheduling_parameters"].key?(key)
+      if attributes["scheduling_parameters"] && !attributes["scheduling_parameters"].key?(key)
         attributes["scheduling_parameters"][key] = value
       end
     end
diff --git a/services/api/test/functional/arvados/v1/container_requests_controller_test.rb b/services/api/test/functional/arvados/v1/container_requests_controller_test.rb
index ceb94fe92..a5e946e19 100644
--- a/services/api/test/functional/arvados/v1/container_requests_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/container_requests_controller_test.rb
@@ -62,7 +62,7 @@ class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase
     assert_equal 'bar', req.secret_mounts['/foo']['content']
   end
 
-  test "runtime constraints with default values" do
+  test "cancel with runtime_constraints and scheduling_params with default values" do
     authorize_with :active
     req = container_requests(:queued)
 
@@ -77,7 +77,7 @@ class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase
           'keep_cache_ram' => 0,
         },
         scheduling_parameters: {
-          "preemptible"=>false
+          "preemptible"=>nil
         }
       },
     }

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list