[ARVADOS] created: 1.3.0-955-g435a5df3e

Git user git at public.curoverse.com
Tue May 28 15:05:09 UTC 2019


        at  435a5df3e505dfbf67467bd02073f97e63c4c61d (commit)


commit 435a5df3e505dfbf67467bd02073f97e63c4c61d
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Tue May 28 11:04:35 2019 -0400

    14878: Skip flock() when testing priority updater.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/services/api/lib/update_priority.rb b/services/api/lib/update_priority.rb
index 21cd74bae..8bf3e150d 100644
--- a/services/api/lib/update_priority.rb
+++ b/services/api/lib/update_priority.rb
@@ -12,14 +12,14 @@ module UpdatePriority
   #
   # If container priority=0 but there are committed container requests
   # for it with priority>0, update priority.
-  def self.update_priority
+  def self.update_priority(nolock: false)
     if !File.owned?(Rails.root.join('tmp'))
       Rails.logger.warn("UpdatePriority: not owner of #{Rails.root}/tmp, skipping")
       return
     end
     lockfile = Rails.root.join('tmp', 'update_priority.lock')
     File.open(lockfile, File::RDWR|File::CREAT, 0600) do |f|
-      return unless f.flock(File::LOCK_NB|File::LOCK_EX)
+      return unless nolock || f.flock(File::LOCK_NB|File::LOCK_EX)
 
       # priority>0 but should be 0:
       ActiveRecord::Base.connection.
diff --git a/services/api/test/unit/update_priority_test.rb b/services/api/test/unit/update_priority_test.rb
index 2d28d3fb6..c1f60d91d 100644
--- a/services/api/test/unit/update_priority_test.rb
+++ b/services/api/test/unit/update_priority_test.rb
@@ -10,13 +10,13 @@ class UpdatePriorityTest < ActiveSupport::TestCase
     uuid = containers(:running).uuid
     ActiveRecord::Base.connection.exec_query('UPDATE containers SET priority=0 WHERE uuid=$1', 'test-setup', [[nil, uuid]])
     assert_equal 0, Container.find_by_uuid(uuid).priority
-    UpdatePriority.update_priority
+    UpdatePriority.update_priority(nolock: true)
     assert_operator 0, :<, Container.find_by_uuid(uuid).priority
 
     uuid = containers(:queued).uuid
     ActiveRecord::Base.connection.exec_query('UPDATE containers SET priority=0 WHERE uuid=$1', 'test-setup', [[nil, uuid]])
     assert_equal 0, Container.find_by_uuid(uuid).priority
-    UpdatePriority.update_priority
+    UpdatePriority.update_priority(nolock: true)
     assert_operator 0, :<, Container.find_by_uuid(uuid).priority
   end
 
@@ -24,7 +24,7 @@ class UpdatePriorityTest < ActiveSupport::TestCase
     uuid = containers(:running).uuid
     ActiveRecord::Base.connection.exec_query('DELETE FROM container_requests WHERE container_uuid=$1', 'test-setup', [[nil, uuid]])
     assert_operator 0, :<, Container.find_by_uuid(uuid).priority
-    UpdatePriority.update_priority
+    UpdatePriority.update_priority(nolock: true)
     assert_equal 0, Container.find_by_uuid(uuid).priority
   end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list