Commit 94716c27 authored by James Lopez's avatar James Lopez

remove unnecessary lease as cron job

parent 44ec4002
...@@ -2,12 +2,9 @@ class StuckImportJobsWorker ...@@ -2,12 +2,9 @@ class StuckImportJobsWorker
include Sidekiq::Worker include Sidekiq::Worker
include CronjobQueue include CronjobQueue
EXCLUSIVE_LEASE_KEY = 'fail_stuck_imports_worker_lease'.freeze
IMPORT_EXPIRATION = 15.hours.to_i IMPORT_EXPIRATION = 15.hours.to_i
def perform def perform
return unless try_obtain_lease
stuck_projects.find_in_batches(batch_size: 500) do |group| stuck_projects.find_in_batches(batch_size: 500) do |group|
jids = group.map(&:import_jid) jids = group.map(&:import_jid)
...@@ -20,8 +17,6 @@ class StuckImportJobsWorker ...@@ -20,8 +17,6 @@ class StuckImportJobsWorker
fail_batch!(completed_jids, completed_ids) fail_batch!(completed_jids, completed_ids)
end end
end end
remove_lease
end end
private private
...@@ -39,12 +34,4 @@ class StuckImportJobsWorker ...@@ -39,12 +34,4 @@ class StuckImportJobsWorker
def error_message def error_message
"Import timed out. Import took longer than #{IMPORT_EXPIRATION} seconds" "Import timed out. Import took longer than #{IMPORT_EXPIRATION} seconds"
end end
def try_obtain_lease
@uuid = Gitlab::ExclusiveLease.new(EXCLUSIVE_LEASE_KEY, timeout: 30.minutes).try_obtain
end
def remove_lease
Gitlab::ExclusiveLease.cancel(EXCLUSIVE_LEASE_KEY, @uuid)
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment