mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-08-20 14:11:11 +00:00
Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
@ -58,8 +58,8 @@ class CommitStatus < Ci::ApplicationRecord
|
||||
scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) }
|
||||
scope :eager_load_pipeline, -> { eager_load(:pipeline, project: { namespace: :route }) }
|
||||
scope :with_pipeline, -> { joins(:pipeline) }
|
||||
scope :created_at_before, ->(date) { where('ci_builds.created_at < ?', date) }
|
||||
scope :updated_at_before, ->(date) { where('ci_builds.updated_at < ?', date) }
|
||||
scope :created_at_before, ->(date) { where('ci_builds.created_at < ?', date) }
|
||||
scope :updated_before, ->(lookback:, timeout:) {
|
||||
where('(ci_builds.created_at BETWEEN ? AND ?) AND (ci_builds.updated_at BETWEEN ? AND ?)', lookback, timeout, lookback, timeout)
|
||||
}
|
||||
|
@ -63,12 +63,10 @@ class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker
|
||||
end
|
||||
|
||||
def running_timed_out_builds
|
||||
if Feature.enabled?(:ci_new_query_for_running_stuck_jobs)
|
||||
running_builds = Ci::Build.running.created_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago).order(created_at: :asc, project_id: :asc) # rubocop: disable CodeReuse/ActiveRecord
|
||||
Ci::Build.id_in(running_builds).updated_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago)
|
||||
else
|
||||
Ci::Build.running.updated_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago)
|
||||
end
|
||||
Ci::Build.running.where( # rubocop: disable CodeReuse/ActiveRecord
|
||||
'ci_builds.updated_at < ?',
|
||||
BUILD_RUNNING_OUTDATED_TIMEOUT.ago
|
||||
)
|
||||
end
|
||||
|
||||
def try_obtain_lease
|
||||
|
@ -1,8 +0,0 @@
|
||||
---
|
||||
name: ci_new_query_for_running_stuck_jobs
|
||||
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68891
|
||||
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/339264
|
||||
milestone: '14.3'
|
||||
type: development
|
||||
group: group::pipeline execution
|
||||
default_enabled: false
|
@ -186,32 +186,20 @@ RSpec.describe StuckCiJobsWorker do
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'job is running' do
|
||||
context 'when job is running' do
|
||||
let(:status) { 'running' }
|
||||
context 'when job is running' do
|
||||
let(:status) { 'running' }
|
||||
|
||||
context 'when job was updated_at more than an hour ago' do
|
||||
let(:updated_at) { 2.hours.ago }
|
||||
context 'when job was updated_at more than an hour ago' do
|
||||
let(:updated_at) { 2.hours.ago }
|
||||
|
||||
it_behaves_like 'job is dropped'
|
||||
end
|
||||
|
||||
context 'when job was updated in less than 1 hour ago' do
|
||||
let(:updated_at) { 30.minutes.ago }
|
||||
|
||||
it_behaves_like 'job is unchanged'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'job is running'
|
||||
|
||||
context 'when ci_new_query_for_running_stuck_jobs feature flag is disabled' do
|
||||
before do
|
||||
stub_feature_flags(ci_new_query_for_running_stuck_jobs: false)
|
||||
it_behaves_like 'job is dropped'
|
||||
end
|
||||
|
||||
it_behaves_like 'job is running'
|
||||
context 'when job was updated in less than 1 hour ago' do
|
||||
let(:updated_at) { 30.minutes.ago }
|
||||
|
||||
it_behaves_like 'job is unchanged'
|
||||
end
|
||||
end
|
||||
|
||||
%w(success skipped failed canceled).each do |status|
|
||||
|
Reference in New Issue
Block a user