2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2021-10-07 08:12:09 -04:00
|
|
|
include ExclusiveLeaseGuard
|
2021-04-30 14:10:09 -04:00
|
|
|
|
2021-09-13 14:11:46 -04:00
|
|
|
# rubocop:disable Scalability/CronWorkerContext
|
|
|
|
# This is an instance-wide cleanup query, so there's no meaningful
|
|
|
|
# scope to consider this in the context of.
|
2020-02-10 13:09:00 -05:00
|
|
|
include CronjobQueue
|
2021-09-13 14:11:46 -04:00
|
|
|
# rubocop:enable Scalability/CronWorkerContext
|
|
|
|
|
|
|
|
data_consistency :always
|
2015-10-21 05:29:47 -04:00
|
|
|
|
2019-10-18 07:11:44 -04:00
|
|
|
feature_category :continuous_integration
|
|
|
|
|
2015-10-21 05:29:47 -04:00
|
|
|
def perform
|
2021-09-29 17:12:32 -04:00
|
|
|
Ci::StuckBuilds::DropRunningWorker.perform_in(20.minutes)
|
2021-10-04 20:12:25 -04:00
|
|
|
Ci::StuckBuilds::DropScheduledWorker.perform_in(40.minutes)
|
2021-09-29 17:12:32 -04:00
|
|
|
|
2021-10-07 08:12:09 -04:00
|
|
|
try_obtain_lease do
|
2021-10-08 08:11:10 -04:00
|
|
|
Ci::StuckBuilds::DropPendingService.new.execute
|
2021-10-04 08:11:58 -04:00
|
|
|
end
|
2017-02-07 08:00:46 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-10-07 08:12:09 -04:00
|
|
|
def lease_timeout
|
|
|
|
30.minutes
|
2017-02-08 21:29:38 -05:00
|
|
|
end
|
2015-10-21 05:29:47 -04:00
|
|
|
end
|