Commit 24255d19 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'ci-add-ci_pending_builds_maintain_denormalized_data-ff' into 'master'

Merge maintain feature flags for new queuing mechanism

See merge request gitlab-org/gitlab!75425
parents dc96eabb 9ccc7c29
...@@ -30,6 +30,10 @@ module Ci ...@@ -30,6 +30,10 @@ module Ci
self.upsert(entry.attributes.compact, returning: %w[build_id], unique_by: :build_id) self.upsert(entry.attributes.compact, returning: %w[build_id], unique_by: :build_id)
end end
def maintain_denormalized_data?
::Feature.enabled?(:ci_pending_builds_maintain_denormalized_data, default_enabled: :yaml)
end
private private
def args_from_build(build) def args_from_build(build)
...@@ -42,15 +46,9 @@ module Ci ...@@ -42,15 +46,9 @@ module Ci
namespace: project.namespace namespace: project.namespace
} }
if Feature.enabled?(:ci_pending_builds_maintain_tags_data, type: :development, default_enabled: :yaml) if maintain_denormalized_data?
args.store(:tag_ids, build.tags_ids) args.store(:tag_ids, build.tags_ids)
end
if Feature.enabled?(:ci_pending_builds_maintain_shared_runners_data, type: :development, default_enabled: :yaml)
args.store(:instance_runners_enabled, shared_runners_enabled?(project)) args.store(:instance_runners_enabled, shared_runners_enabled?(project))
end
if Feature.enabled?(:ci_pending_builds_maintain_namespace_traversal_ids, type: :development, default_enabled: :yaml)
args.store(:namespace_traversal_ids, project.namespace.traversal_ids) if group_runners_enabled?(project) args.store(:namespace_traversal_ids, project.namespace.traversal_ids) if group_runners_enabled?(project)
end end
......
...@@ -14,7 +14,7 @@ module Ci ...@@ -14,7 +14,7 @@ module Ci
# Add a build to the pending builds queue # Add a build to the pending builds queue
# #
def push(build, transition) def push(build, transition)
return unless maintain_pending_builds_queue?(build) return unless maintain_pending_builds_queue?
raise InvalidQueueTransition unless transition.to == 'pending' raise InvalidQueueTransition unless transition.to == 'pending'
...@@ -33,7 +33,7 @@ module Ci ...@@ -33,7 +33,7 @@ module Ci
# Remove a build from the pending builds queue # Remove a build from the pending builds queue
# #
def pop(build, transition) def pop(build, transition)
return unless maintain_pending_builds_queue?(build) return unless maintain_pending_builds_queue?
raise InvalidQueueTransition unless transition.from == 'pending' raise InvalidQueueTransition unless transition.from == 'pending'
...@@ -52,7 +52,7 @@ module Ci ...@@ -52,7 +52,7 @@ module Ci
# Add shared runner build tracking entry (used for queuing). # Add shared runner build tracking entry (used for queuing).
# #
def track(build, transition) def track(build, transition)
return unless Feature.enabled?(:ci_track_shared_runner_builds, build.project, default_enabled: :yaml) return unless maintain_pending_builds_queue?
return unless build.shared_runner_build? return unless build.shared_runner_build?
raise InvalidQueueTransition unless transition.to == 'running' raise InvalidQueueTransition unless transition.to == 'running'
...@@ -73,7 +73,7 @@ module Ci ...@@ -73,7 +73,7 @@ module Ci
# queuing). # queuing).
# #
def untrack(build, transition) def untrack(build, transition)
return unless Feature.enabled?(:ci_untrack_shared_runner_builds, build.project, default_enabled: :yaml) return unless maintain_pending_builds_queue?
return unless build.shared_runner_build? return unless build.shared_runner_build?
raise InvalidQueueTransition unless transition.from == 'running' raise InvalidQueueTransition unless transition.from == 'running'
...@@ -113,8 +113,8 @@ module Ci ...@@ -113,8 +113,8 @@ module Ci
end end
end end
def maintain_pending_builds_queue?(build) def maintain_pending_builds_queue?
Feature.enabled?(:ci_pending_builds_queue_maintain, build.project, default_enabled: :yaml) ::Ci::PendingBuild.maintain_denormalized_data?
end end
end end
end end
...@@ -15,7 +15,7 @@ module Ci ...@@ -15,7 +15,7 @@ module Ci
end end
def execute def execute
return unless ::Feature.enabled?(:ci_pending_builds_maintain_shared_runners_data, @model, default_enabled: :yaml) return unless ::Ci::PendingBuild.maintain_denormalized_data?
@model.pending_builds.each_batch do |relation| @model.pending_builds.each_batch do |relation|
relation.update_all(@update_params) relation.update_all(@update_params)
......
--- ---
name: ci_pending_builds_maintain_ci_minutes_data name: ci_pending_builds_maintain_denormalized_data
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64443 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75425
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338149 rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/332951
milestone: '14.2' milestone: '14.6'
type: development type: development
group: group::pipeline execution group: group::pipeline execution
default_enabled: false default_enabled: true
---
name: ci_pending_builds_maintain_namespace_traversal_ids
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70162
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/340930
milestone: '14.3'
type: development
group: group::pipeline execution
default_enabled: false
---
name: ci_pending_builds_maintain_shared_runners_data
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64644
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338152
milestone: '14.1'
type: development
group: group::pipeline execution
default_enabled: false
---
name: ci_pending_builds_maintain_tags_data
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65648
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338363
milestone: '14.2'
type: development
group: group::pipeline execution
default_enabled: false
---
name: ci_pending_builds_queue_maintain
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61581
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/331496
milestone: '13.12'
type: development
group: group::pipeline execution
default_enabled: false
---
name: ci_track_shared_runner_builds
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62912
rollout_issue_url:
milestone: '14.0'
type: development
group: group::pipeline execution
default_enabled: false
---
name: ci_untrack_shared_runner_builds
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62912
rollout_issue_url:
milestone: '14.0'
type: development
group: group::pipeline execution
default_enabled: false
...@@ -14,12 +14,7 @@ module EE ...@@ -14,12 +14,7 @@ module EE
override :args_from_build override :args_from_build
def args_from_build(build) def args_from_build(build)
return super unless ::Feature.enabled?( return super unless maintain_denormalized_data?
:ci_pending_builds_maintain_ci_minutes_data,
build&.project&.root_namespace,
type: :development,
default_enabled: :yaml
)
super.merge(minutes_exceeded: minutes_exceeded?(build.project)) super.merge(minutes_exceeded: minutes_exceeded?(build.project))
end end
......
...@@ -27,7 +27,7 @@ module Ci ...@@ -27,7 +27,7 @@ module Ci
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def update_pending_builds! def update_pending_builds!
return unless ::Feature.enabled?(:ci_pending_builds_maintain_ci_minutes_data, @root_namespace, type: :development, default_enabled: :yaml) return unless ::Ci::PendingBuild.maintain_denormalized_data?
minutes_exceeded = @root_namespace.ci_minutes_quota.minutes_used_up? minutes_exceeded = @root_namespace.ci_minutes_quota.minutes_used_up?
all_namespace_ids = @root_namespace.self_and_descendant_ids.ids all_namespace_ids = @root_namespace.self_and_descendant_ids.ids
......
...@@ -59,13 +59,13 @@ RSpec.describe Ci::PendingBuild do ...@@ -59,13 +59,13 @@ RSpec.describe Ci::PendingBuild do
allow(::Ci::Runner).to receive(:any_shared_runners_with_enabled_cost_factor?).and_return(true) allow(::Ci::Runner).to receive(:any_shared_runners_with_enabled_cost_factor?).and_return(true)
end end
context 'when ci_pending_builds_maintain_ci_minutes_data is enabled' do context 'when ci_pending_builds_maintain_denormalized_data is enabled' do
it_behaves_like 'ci minutes not available' it_behaves_like 'ci minutes not available'
end end
context 'when ci_pending_builds_maintain_ci_minutes_data is disabled' do context 'when ci_pending_builds_maintain_denormalized_data is disabled' do
before do before do
stub_feature_flags(ci_pending_builds_maintain_ci_minutes_data: false) stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end end
it_behaves_like 'ci minutes available' it_behaves_like 'ci minutes available'
...@@ -73,13 +73,13 @@ RSpec.describe Ci::PendingBuild do ...@@ -73,13 +73,13 @@ RSpec.describe Ci::PendingBuild do
end end
context 'when project does not matches shared runners with cost factor enabled' do context 'when project does not matches shared runners with cost factor enabled' do
context 'when ci_pending_builds_maintain_ci_minutes_data is enabled' do context 'when ci_pending_builds_maintain_denormalized_data is enabled' do
it_behaves_like 'ci minutes available' it_behaves_like 'ci minutes available'
end end
context 'when ci_pending_builds_maintain_ci_minutes_data is disabled' do context 'when ci_pending_builds_maintain_denormalized_data is disabled' do
before do before do
stub_feature_flags(ci_pending_builds_maintain_ci_minutes_data: false) stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end end
it_behaves_like 'ci minutes available' it_behaves_like 'ci minutes available'
...@@ -88,13 +88,13 @@ RSpec.describe Ci::PendingBuild do ...@@ -88,13 +88,13 @@ RSpec.describe Ci::PendingBuild do
end end
context 'when ci minutes are available' do context 'when ci minutes are available' do
context 'when ci_pending_builds_maintain_ci_minutes_data is enabled' do context 'when ci_pending_builds_maintain_denormalized_data is enabled' do
it_behaves_like 'ci minutes available' it_behaves_like 'ci minutes available'
end end
context 'when ci_pending_builds_maintain_ci_minutes_data is disabled' do context 'when ci_pending_builds_maintain_denormalized_data is disabled' do
before do before do
stub_feature_flags(ci_pending_builds_maintain_ci_minutes_data: false) stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end end
it_behaves_like 'ci minutes available' it_behaves_like 'ci minutes available'
......
...@@ -61,9 +61,9 @@ RSpec.describe Ci::Minutes::RefreshCachedDataService do ...@@ -61,9 +61,9 @@ RSpec.describe Ci::Minutes::RefreshCachedDataService do
end end
end end
context 'when ci_pending_builds_maintain_ci_minutes_data is disabled' do context 'when ci_pending_builds_maintain_denormalized_data is disabled' do
before do before do
stub_feature_flags(ci_pending_builds_maintain_ci_minutes_data: false) stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end end
it 'does not update pending builds' do it 'does not update pending builds' do
......
...@@ -118,7 +118,7 @@ RSpec.describe Ci::PendingBuild do ...@@ -118,7 +118,7 @@ RSpec.describe Ci::PendingBuild do
project.shared_runners_enabled = true project.shared_runners_enabled = true
end end
context 'when ci_pending_builds_maintain_shared_runners_data is enabled' do context 'when ci_pending_builds_maintain_denormalized_data is enabled' do
it 'sets instance_runners_enabled to true' do it 'sets instance_runners_enabled to true' do
described_class.upsert_from_build!(build) described_class.upsert_from_build!(build)
...@@ -150,9 +150,9 @@ RSpec.describe Ci::PendingBuild do ...@@ -150,9 +150,9 @@ RSpec.describe Ci::PendingBuild do
end end
end end
context 'when ci_pending_builds_maintain_shared_runners_data is disabled' do context 'when ci_pending_builds_maintain_denormalized_data is disabled' do
before do before do
stub_feature_flags(ci_pending_builds_maintain_shared_runners_data: false) stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end end
it 'sets instance_runners_enabled to false' do it 'sets instance_runners_enabled to false' do
...@@ -168,7 +168,7 @@ RSpec.describe Ci::PendingBuild do ...@@ -168,7 +168,7 @@ RSpec.describe Ci::PendingBuild do
subject(:ci_pending_build) { described_class.last } subject(:ci_pending_build) { described_class.last }
context 'when ci_pending_builds_maintain_tags_data is enabled' do context 'when ci_pending_builds_maintain_denormalized_data is enabled' do
it 'sets tag_ids' do it 'sets tag_ids' do
described_class.upsert_from_build!(build) described_class.upsert_from_build!(build)
...@@ -176,9 +176,9 @@ RSpec.describe Ci::PendingBuild do ...@@ -176,9 +176,9 @@ RSpec.describe Ci::PendingBuild do
end end
end end
context 'when ci_pending_builds_maintain_tags_data is disabled' do context 'when ci_pending_builds_maintain_denormalized_data is disabled' do
before do before do
stub_feature_flags(ci_pending_builds_maintain_tags_data: false) stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end end
it 'does not set tag_ids' do it 'does not set tag_ids' do
......
...@@ -43,9 +43,9 @@ RSpec.describe Ci::UpdatePendingBuildService do ...@@ -43,9 +43,9 @@ RSpec.describe Ci::UpdatePendingBuildService do
expect(pending_build_2.instance_runners_enabled).to be_truthy expect(pending_build_2.instance_runners_enabled).to be_truthy
end end
context 'when ci_pending_builds_maintain_shared_runners_data is disabled' do context 'when ci_pending_builds_maintain_denormalized_data is disabled' do
before do before do
stub_feature_flags(ci_pending_builds_maintain_shared_runners_data: false) stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end end
it 'does not update all pending builds', :aggregate_failures do it 'does not update all pending builds', :aggregate_failures do
...@@ -67,9 +67,9 @@ RSpec.describe Ci::UpdatePendingBuildService do ...@@ -67,9 +67,9 @@ RSpec.describe Ci::UpdatePendingBuildService do
expect(pending_build_2.instance_runners_enabled).to be_truthy expect(pending_build_2.instance_runners_enabled).to be_truthy
end end
context 'when ci_pending_builds_maintain_shared_runners_data is disabled' do context 'when ci_pending_builds_maintain_denormalized_data is disabled' do
before do before do
stub_feature_flags(ci_pending_builds_maintain_shared_runners_data: false) stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end end
it 'does not update all pending builds', :aggregate_failures do it 'does not update all pending builds', :aggregate_failures do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment