2021-10-04 20:12:25 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Ci
|
|
|
|
module StuckBuilds
|
|
|
|
class DropScheduledService
|
|
|
|
include DropHelpers
|
|
|
|
|
|
|
|
BUILD_SCHEDULED_OUTDATED_TIMEOUT = 1.hour
|
|
|
|
|
|
|
|
def execute
|
|
|
|
Gitlab::AppLogger.info "#{self.class}: Cleaning scheduled, timed-out builds"
|
|
|
|
|
|
|
|
drop(scheduled_timed_out_builds, failure_reason: :stale_schedule)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def scheduled_timed_out_builds
|
2021-10-06 17:12:16 -04:00
|
|
|
Ci::Build.scheduled.scheduled_at_before(BUILD_SCHEDULED_OUTDATED_TIMEOUT.ago)
|
2021-10-04 20:12:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|