gitlab-org--gitlab-foss/app/workers/stuck_ci_jobs_worker.rb

32 lines
761 B
Ruby
Raw Normal View History

# frozen_string_literal: true
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
# scope to consider this in the context of.
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
data_consistency :always
2015-10-21 05:29:47 -04:00
feature_category :continuous_integration
2015-10-21 05:29:47 -04:00
def perform
Ci::StuckBuilds::DropRunningWorker.perform_in(20.minutes)
Ci::StuckBuilds::DropScheduledWorker.perform_in(40.minutes)
try_obtain_lease do
Ci::StuckBuilds::DropPendingService.new.execute
end
end
private
def lease_timeout
30.minutes
2017-02-08 21:29:38 -05:00
end
2015-10-21 05:29:47 -04:00
end