[ARVADOS] created: 84b73bac77e316376c4ecfb9aebd1b6c564d77f9

Git user git at public.curoverse.com
Thu Jul 6 20:57:16 EDT 2017


        at  84b73bac77e316376c4ecfb9aebd1b6c564d77f9 (commit)


commit 84b73bac77e316376c4ecfb9aebd1b6c564d77f9
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/controllers/arvados/v1/container_requests_controller.rb b/services/api/app/controllers/arvados/v1/container_requests_controller.rb
index c5da06e..b03fd75 100644
--- a/services/api/app/controllers/arvados/v1/container_requests_controller.rb
+++ b/services/api/app/controllers/arvados/v1/container_requests_controller.rb
@@ -9,4 +9,9 @@ class Arvados::V1::ContainerRequestsController < ApplicationController
   accept_attribute_as_json :command, Array
   accept_attribute_as_json :filters, Array
   accept_attribute_as_json :scheduling_parameters, Hash
+
+  def destroy
+    @object.update_attributes!(priority: 0) if @object.state != ContainerRequest::Final
+    super
+  end
 end
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/functional/arvados/v1/container_requests_controller_test.rb b/services/api/test/functional/arvados/v1/container_requests_controller_test.rb
index 4ebda97..4713a4a 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
@@ -23,4 +23,19 @@ class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase
     assert_not_nil cr, 'Expected container request'
     assert_equal sp, cr['scheduling_parameters']
   end
+
+  test "delete container_request and check its container's priority" do
+    authorize_with :active
+
+    # initially the container's priority is 1
+    c = Container.find_by_uuid containers(:running_to_be_deleted).uuid
+    assert_equal 1, c.priority
+
+    post :destroy, id: container_requests(:running_to_be_deleted).uuid
+    assert_response :success
+
+    # now the container's priority should be set to zero
+    c = Container.find_by_uuid containers(:running_to_be_deleted).uuid
+    assert_equal 0, c.priority
+  end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list