debian-mirror-gitlab/app/workers/stuck_ci_jobs_worker.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
761 B
Ruby
Raw Permalink Normal View History

2018-11-08 19:23:39 +05:30
# frozen_string_literal: true
2020-04-08 14:13:33 +05:30
class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker
2018-03-17 18:26:18 +05:30
include ApplicationWorker
2021-11-18 22:05:49 +05:30
include ExclusiveLeaseGuard
2021-06-08 01:23:25 +05:30
2021-11-11 11:23:49 +05:30
# rubocop:disable Scalability/CronWorkerContext
# This is an instance-wide cleanup query, so there's no meaningful
# scope to consider this in the context of.
2017-08-17 22:00:37 +05:30
include CronjobQueue
2021-11-11 11:23:49 +05:30
# rubocop:enable Scalability/CronWorkerContext
data_consistency :always
2017-08-17 22:00:37 +05:30
2019-12-21 20:55:43 +05:30
feature_category :continuous_integration
2017-08-17 22:00:37 +05:30
def perform
2021-11-18 22:05:49 +05:30
Ci::StuckBuilds::DropRunningWorker.perform_in(20.minutes)
Ci::StuckBuilds::DropScheduledWorker.perform_in(40.minutes)
2017-08-17 22:00:37 +05:30
2021-11-18 22:05:49 +05:30
try_obtain_lease do
Ci::StuckBuilds::DropPendingService.new.execute
end
2017-08-17 22:00:37 +05:30
end
private
2021-11-18 22:05:49 +05:30
def lease_timeout
30.minutes
2017-08-17 22:00:37 +05:30
end
end