Skip to content
Snippets Groups Projects
Commit 94716c27 authored by James Lopez's avatar James Lopez
Browse files

remove unnecessary lease as cron job

parent 44ec4002
No related branches found
No related tags found
No related merge requests found
Loading
@@ -2,12 +2,9 @@ class StuckImportJobsWorker
Loading
@@ -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)
   
Loading
@@ -20,8 +17,6 @@ class StuckImportJobsWorker
Loading
@@ -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
Loading
@@ -39,12 +34,4 @@ class StuckImportJobsWorker
Loading
@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment