[ARVADOS] updated: 2.1.0-232-gaf2ce3cfa

Git user git at public.arvados.org
Mon Jan 4 18:07:51 UTC 2021


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  af2ce3cfafb4d4aa3d215b812f22e8db8ff4a9b4 (commit)
      from  edaa163c7c65c1a577a9744d7eee6cc1cd46ca6c (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 af2ce3cfafb4d4aa3d215b812f22e8db8ff4a9b4
Author: Nico Cesar <nico at nicocesar.com>
Date:   Mon Jan 4 13:07:40 2021 -0500

    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 0e650bbeb..fc1961127 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