[arvados] updated: 2.6.0-535-gad040e3743

git repository hosting git at public.arvados.org
Tue Aug 29 15:04:26 UTC 2023


Summary of changes:
 services/api/app/models/container_request.rb     |  7 +++++++
 services/api/app/models/group.rb                 |  6 ++++++
 services/api/test/unit/container_request_test.rb | 16 ++++++++++++++++
 3 files changed, 29 insertions(+)

       via  ad040e37430803ffa7db4f1856a4e362ad2cebfe (commit)
      from  1c4bf0f3bbc09808f4937dafa6c3023604b73dce (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 ad040e37430803ffa7db4f1856a4e362ad2cebfe
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Tue Aug 29 11:04:03 2023 -0400

    20877: Do not create log or output collections if parent is frozen or trashed
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index 3c3896771e..d72f00edc8 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -232,6 +232,13 @@ class ContainerRequest < ArvadosModel
   end
 
   def update_collections(container:, collections: ['log', 'output'])
+
+    # Check if parent is frozen or trashed, in which case it isn't
+    # valid to create new collections in the project, so return
+    # without creating anything.
+    owner = Group.find_by_uuid(self.owner_uuid)
+    return if owner && !owner.admin_change_permitted
+
     collections.each do |out_type|
       pdh = container.send(out_type)
       next if pdh.nil?
diff --git a/services/api/app/models/group.rb b/services/api/app/models/group.rb
index 09bb8af97d..5c0aeba589 100644
--- a/services/api/app/models/group.rb
+++ b/services/api/app/models/group.rb
@@ -49,6 +49,12 @@ class Group < ArvadosModel
     t.add :can_manage
   end
 
+  # check if admins are allowed to make changes to the project, e.g. it
+  # isn't trashed or frozen.
+  def admin_change_permitted
+    !(FrozenGroup.where(uuid: self.uuid).any? || TrashedGroup.where(group_uuid: self.uuid).any?)
+  end
+
   protected
 
   def self.attributes_required_columns
diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 71cb9d7301..a64adba6ff 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -1498,6 +1498,22 @@ class ContainerRequestTest < ActiveSupport::TestCase
       # the cr's container now has priority of 0
       c.reload
       assert_equal 0, c.priority
+
+      assert_equal c.state, 'Running'
+      assert_equal cr.state, 'Committed'
+
+      # mark the container as cancelled, this should cause the
+      # container request to go to final state and run the finalize
+      # function
+      act_as_system_user do
+        c.update_attributes!(state: 'Cancelled', log: 'fa7aeb5140e2848d39b416daeef4ffc5+45')
+      end
+      c.reload
+      cr.reload
+
+      assert_equal c.state, 'Cancelled'
+      assert_equal cr.state, 'Final'
+      assert_equal nil, cr.log_uuid
     end
   end
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list