[ARVADOS] updated: 3a5b003b5cf784e96799d8ddadc939834620fd34

Git user git at public.curoverse.com
Mon Jul 17 12:09:31 EDT 2017


Summary of changes:
 services/api/app/models/container_request.rb      |  5 +++++
 services/api/test/fixtures/container_requests.yml | 19 ++++++++++++++++++
 services/api/test/fixtures/containers.yml         | 17 ++++++++++++++++
 services/api/test/unit/container_request_test.rb  | 24 +++++++++++++++++++++++
 4 files changed, 65 insertions(+)

       via  3a5b003b5cf784e96799d8ddadc939834620fd34 (commit)
       via  63e12fa3f15d417526db4f743108fe4eedcfcad0 (commit)
      from  bf87f4aba81caff15b174393faf074cf9d8ba554 (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 3a5b003b5cf784e96799d8ddadc939834620fd34
Merge: bf87f4a 63e12fa
Author: radhika <radhika at curoverse.com>
Date:   Mon Jul 17 11:52:58 2017 -0400

    closes #11682
    
    Merge branch '11682-delete-container-request'
    
    Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika at curoverse.com>


commit 63e12fa3f15d417526db4f743108fe4eedcfcad0
Author: radhika <radhika at curoverse.com>
Date:   Thu Jul 6 20:46:24 2017 -0400

    11682: when a container_request is being destroyed, update it's container's priority
    
    Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika at curoverse.com>

diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index e8ab0cb..94e4e1f 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -28,6 +28,7 @@ class ContainerRequest < ArvadosModel
   after_save :update_priority
   after_save :finalize_if_needed
   before_create :set_requesting_container_uuid
+  before_destroy :set_priority_zero
 
   api_accessible :user, extend: :common do |t|
     t.add :command
@@ -262,6 +263,10 @@ class ContainerRequest < ArvadosModel
     end
   end
 
+  def set_priority_zero
+    self.update_attributes!(priority: 0) if self.state != Final
+  end
+
   def set_requesting_container_uuid
     return !new_record? if self.requesting_container_uuid   # already set
 
diff --git a/services/api/test/fixtures/container_requests.yml b/services/api/test/fixtures/container_requests.yml
index da138c4..836f840 100644
--- a/services/api/test/fixtures/container_requests.yml
+++ b/services/api/test/fixtures/container_requests.yml
@@ -272,6 +272,25 @@ canceled_with_running_container:
     vcpus: 1
     ram: 123
 
+running_to_be_deleted:
+  uuid: zzzzz-xvhdp-cr5runningcntnr
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  name: running to be deleted
+  state: Committed
+  priority: 1
+  created_at: <%= 2.days.ago.to_s(:db) %>
+  updated_at: <%= 1.days.ago.to_s(:db) %>
+  modified_at: <%= 1.days.ago.to_s(:db) %>
+  modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  container_image: test
+  cwd: test
+  output_path: test
+  command: ["echo", "hello"]
+  container_uuid: zzzzz-dz642-runnincntrtodel
+  runtime_constraints:
+    vcpus: 1
+    ram: 123
+
 completed_with_input_mounts:
   uuid: zzzzz-xvhdp-crwithinputmnts
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
diff --git a/services/api/test/fixtures/containers.yml b/services/api/test/fixtures/containers.yml
index 9293669..a7ad6f0 100644
--- a/services/api/test/fixtures/containers.yml
+++ b/services/api/test/fixtures/containers.yml
@@ -216,3 +216,20 @@ running_container_with_logs:
   runtime_constraints:
     ram: 12000000000
     vcpus: 4
+
+running_to_be_deleted:
+  uuid: zzzzz-dz642-runnincntrtodel
+  owner_uuid: zzzzz-tpzed-000000000000000
+  state: Running
+  priority: 1
+  created_at: <%= 1.minute.ago.to_s(:db) %>
+  updated_at: <%= 1.minute.ago.to_s(:db) %>
+  started_at: <%= 1.minute.ago.to_s(:db) %>
+  container_image: test
+  cwd: test
+  output_path: test
+  command: ["echo", "hello"]
+  runtime_constraints:
+    ram: 12000000000
+    vcpus: 4
+  auth_uuid: zzzzz-gj3su-077z32aux8dg2s2
diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 280e939..e751d61 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -750,4 +750,28 @@ class ContainerRequestTest < ActiveSupport::TestCase
       end
     end
   end
+
+  test "delete container_request and check its container's priority" do
+    act_as_user users(:active) do
+      cr = ContainerRequest.find_by_uuid container_requests(:running_to_be_deleted).uuid
+
+      # initially the cr's container has priority > 0
+      c = Container.find_by_uuid(cr.container_uuid)
+      assert_equal 1, c.priority
+
+      # destroy the cr
+      assert_nothing_raised {cr.destroy}
+
+      # the cr's container now has priority of 0
+      c = Container.find_by_uuid(cr.container_uuid)
+      assert_equal 0, c.priority
+    end
+  end
+
+  test "delete container_request in final state and expect no error due to before_destroy callback" do
+    act_as_user users(:active) do
+      cr = ContainerRequest.find_by_uuid container_requests(:completed).uuid
+      assert_nothing_raised {cr.destroy}
+    end
+  end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list