[ARVADOS] created: 1.3.0-710-gcd3d4a6d0

Git user git at public.curoverse.com
Fri Apr 12 13:55:43 UTC 2019


        at  cd3d4a6d0923c3cb93f73f7a1fc6e16f26d07feb (commit)


commit cd3d4a6d0923c3cb93f73f7a1fc6e16f26d07feb
Author: Eric Biagiotti <ebiagiotti at veritasgenetics.com>
Date:   Fri Apr 12 09:55:33 2019 -0400

    15002: Adds admin feature for cancelling completed containers
    
    Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti at veritasgenetics.com>

diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb
index fb900a993..cd218d2ee 100644
--- a/services/api/app/models/container.rb
+++ b/services/api/app/models/container.rb
@@ -89,7 +89,8 @@ class Container < ArvadosModel
     nil => [Queued],
     Queued => [Locked, Cancelled],
     Locked => [Queued, Running, Cancelled],
-    Running => [Complete, Cancelled]
+    Running => [Complete, Cancelled],
+    Complete => [Cancelled]
   }
 
   def self.limit_index_columns_read
@@ -490,6 +491,8 @@ class Container < ArvadosModel
         permitted.push :finished_at, *progress_attrs
       when Queued, Locked
         permitted.push :finished_at, :log, :runtime_status
+      when Complete
+        permitted -= [:state] unless current_user.andand.is_admin
       end
 
     else
diff --git a/services/api/test/unit/container_test.rb b/services/api/test/unit/container_test.rb
index 5ce3739a3..f036c536c 100644
--- a/services/api/test/unit/container_test.rb
+++ b/services/api/test/unit/container_test.rb
@@ -790,6 +790,22 @@ class ContainerTest < ActiveSupport::TestCase
     assert c.update_attributes(exit_code: 1, state: Container::Complete)
   end
 
+  [:admin,:active_trustedclient].each do |auth|
+    test "state transition from completed to canceled with #{auth}" do
+      set_user_from_auth auth
+      c, _ = minimal_new
+      c.lock
+      c.update_attributes(state: Container::Running)
+      c.update_attributes(state: Container::Complete)
+      if auth == :admin
+        c.update_attributes(state: Container::Cancelled)
+        assert c.valid?
+      else
+        check_illegal_updates(c, [{state: Container::Cancelled}])
+      end
+    end
+  end
+
   test "locked_by_uuid can update log when locked/running, and output when running" do
     set_user_from_auth :active
     logcoll = collections(:real_log_collection)

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list