diff options
Diffstat (limited to 'app/workers/stuck_ci_jobs_worker.rb')
-rw-r--r-- | app/workers/stuck_ci_jobs_worker.rb | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/app/workers/stuck_ci_jobs_worker.rb b/app/workers/stuck_ci_jobs_worker.rb index a2b2686c8d5..72004f7568c 100644 --- a/app/workers/stuck_ci_jobs_worker.rb +++ b/app/workers/stuck_ci_jobs_worker.rb @@ -2,6 +2,7 @@ class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker + include ExclusiveLeaseGuard # rubocop:disable Scalability/CronWorkerContext # This is an instance-wide cleanup query, so there's no meaningful @@ -12,25 +13,19 @@ class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker data_consistency :always feature_category :continuous_integration - worker_resource_boundary :cpu - - EXCLUSIVE_LEASE_KEY = 'stuck_ci_builds_worker_lease' def perform - return unless try_obtain_lease - - Ci::StuckBuilds::DropService.new.execute + Ci::StuckBuilds::DropRunningWorker.perform_in(20.minutes) + Ci::StuckBuilds::DropScheduledWorker.perform_in(40.minutes) - remove_lease + try_obtain_lease do + Ci::StuckBuilds::DropPendingService.new.execute + end end private - 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) + def lease_timeout + 30.minutes end end |