debian-mirror-gitlab/app/services/ci/stuck_builds/drop_running_service.rb

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

32 lines
882 B
Ruby
Raw Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
module Ci
module StuckBuilds
class DropRunningService
include DropHelpers
BUILD_RUNNING_OUTDATED_TIMEOUT = 1.hour
def execute
Gitlab::AppLogger.info "#{self.class}: Cleaning running, timed-out builds"
drop(running_timed_out_builds, failure_reason: :stuck_or_timeout_failure)
end
private
def running_timed_out_builds
2022-07-16 23:28:13 +05:30
if Feature.enabled?(:ci_new_query_for_running_stuck_jobs)
2021-11-18 22:05:49 +05:30
Ci::Build
.running
.created_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago)
.updated_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago)
.order(created_at: :asc, project_id: :asc) # rubocop:disable CodeReuse/ActiveRecord
else
Ci::Build.running.updated_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago)
end
end
end
end
end