[ARVADOS] created: 4a00ceae73e8d76affe6b646832c525355e7897c

Git user git at public.curoverse.com
Thu Jan 5 10:57:21 EST 2017


        at  4a00ceae73e8d76affe6b646832c525355e7897c (commit)


commit 4a00ceae73e8d76affe6b646832c525355e7897c
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Jan 5 10:55:53 2017 -0500

    10808: Exempt "change state to Cancelled" from "locked by uuid" protection.

diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb
index 9556799..2ae7139 100644
--- a/services/api/app/models/job.rb
+++ b/services/api/app/models/job.rb
@@ -423,7 +423,7 @@ class Job < ArvadosModel
           output_changed? or
           log_changed? or
           tasks_summary_changed? or
-          state_changed? or
+          (state_changed? && state != Cancelled) or
           components_changed?
         logger.warn "User #{current_user.uuid if current_user} tried to change protected job attributes on locked #{self.class.to_s} #{uuid_was}"
         return false
diff --git a/services/api/test/unit/job_test.rb b/services/api/test/unit/job_test.rb
index 1f80ea5..761953e 100644
--- a/services/api/test/unit/job_test.rb
+++ b/services/api/test/unit/job_test.rb
@@ -307,6 +307,24 @@ class JobTest < ActiveSupport::TestCase
     assert_equal "Failed", job.state
   end
 
+  test "admin user can cancel a running job despite lock" do
+    set_user_from_auth :active_trustedclient
+    job = Job.create! job_attrs
+    job.lock current_user.uuid
+    assert_equal Job::Running, job.state
+
+    set_user_from_auth :spectator
+    assert_raises do
+      job.update_attributes!(state: Job::Cancelled)
+    end
+
+    set_user_from_auth :admin
+    job.reload
+    assert_equal Job::Running, job.state
+    job.update_attributes!(state: Job::Cancelled)
+    assert_equal Job::Cancelled, job.state
+  end
+
   test "verify job queue position" do
     job1 = Job.create! job_attrs
     assert_equal 'Queued', job1.state, "Incorrect job state for newly created job1"

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list