Commit 910bbbfa authored by Marius Bobin's avatar Marius Bobin

Merge maintain feature flags for new queuing mechanism

Replace all the feature flags used from writing denormalized queuing
data with only one feature flag.

Changelog: other
parent 831b8720
......@@ -42,15 +42,9 @@ module Ci
namespace: project.namespace
}
if Feature.enabled?(:ci_pending_builds_maintain_tags_data, type: :development, default_enabled: :yaml)
if ::Gitlab::Ci::Features.pending_builds_maintain_denormalized_data?(project)
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))
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)
end
......
......@@ -52,7 +52,7 @@ module Ci
# Add shared runner build tracking entry (used for queuing).
#
def track(build, transition)
return unless Feature.enabled?(:ci_track_shared_runner_builds, build.project, default_enabled: :yaml)
return unless maintain_pending_builds_queue?(build)
return unless build.shared_runner_build?
raise InvalidQueueTransition unless transition.to == 'running'
......@@ -73,7 +73,7 @@ module Ci
# queuing).
#
def untrack(build, transition)
return unless Feature.enabled?(:ci_untrack_shared_runner_builds, build.project, default_enabled: :yaml)
return unless maintain_pending_builds_queue?(build)
return unless build.shared_runner_build?
raise InvalidQueueTransition unless transition.from == 'running'
......@@ -114,7 +114,7 @@ module Ci
end
def maintain_pending_builds_queue?(build)
Feature.enabled?(:ci_pending_builds_queue_maintain, build.project, default_enabled: :yaml)
::Gitlab::Ci::Features.pending_builds_maintain_denormalized_data?(build.project)
end
end
end
......@@ -15,7 +15,7 @@ module Ci
end
def execute
return unless ::Feature.enabled?(:ci_pending_builds_maintain_shared_runners_data, @model, default_enabled: :yaml)
return unless ::Gitlab::Ci::Features.pending_builds_maintain_denormalized_data?(@model)
@model.pending_builds.each_batch do |relation|
relation.update_all(@update_params)
......
---
name: ci_pending_builds_maintain_ci_minutes_data
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64443
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338149
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'
name: ci_pending_builds_maintain_denormalized_data
introduced_by_url:
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/332951
milestone: '14.6'
type: development
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_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
override :args_from_build
def args_from_build(build)
return super unless ::Feature.enabled?(
:ci_pending_builds_maintain_ci_minutes_data,
build&.project&.root_namespace,
type: :development,
default_enabled: :yaml
)
return super unless ::Gitlab::Ci::Features.pending_builds_maintain_denormalized_data?(build&.project&.root_namespace)
super.merge(minutes_exceeded: minutes_exceeded?(build.project))
end
......
......@@ -27,7 +27,7 @@ module Ci
# rubocop: disable CodeReuse/ActiveRecord
def update_pending_builds!
return unless ::Feature.enabled?(:ci_pending_builds_maintain_ci_minutes_data, @root_namespace, type: :development, default_enabled: :yaml)
return unless ::Gitlab::Ci::Features.pending_builds_maintain_denormalized_data?(@root_namespace)
minutes_exceeded = @root_namespace.ci_minutes_quota.minutes_used_up?
all_namespace_ids = @root_namespace.self_and_descendant_ids.ids
......
......@@ -59,13 +59,13 @@ RSpec.describe Ci::PendingBuild do
allow(::Ci::Runner).to receive(:any_shared_runners_with_enabled_cost_factor?).and_return(true)
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'
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
stub_feature_flags(ci_pending_builds_maintain_ci_minutes_data: false)
stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end
it_behaves_like 'ci minutes available'
......@@ -73,13 +73,13 @@ RSpec.describe Ci::PendingBuild do
end
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'
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
stub_feature_flags(ci_pending_builds_maintain_ci_minutes_data: false)
stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end
it_behaves_like 'ci minutes available'
......@@ -88,13 +88,13 @@ RSpec.describe Ci::PendingBuild do
end
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'
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
stub_feature_flags(ci_pending_builds_maintain_ci_minutes_data: false)
stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end
it_behaves_like 'ci minutes available'
......
......@@ -61,9 +61,9 @@ RSpec.describe Ci::Minutes::RefreshCachedDataService do
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
stub_feature_flags(ci_pending_builds_maintain_ci_minutes_data: false)
stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end
it 'does not update pending builds' do
......
......@@ -25,6 +25,10 @@ module Gitlab
def self.gldropdown_tags_enabled?
::Feature.enabled?(:gldropdown_tags, default_enabled: :yaml)
end
def self.pending_builds_maintain_denormalized_data?(actor)
::Feature.enabled?(:ci_pending_builds_maintain_denormalized_data, actor, default_enabled: :yaml)
end
end
end
end
......@@ -118,7 +118,7 @@ RSpec.describe Ci::PendingBuild do
project.shared_runners_enabled = true
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
described_class.upsert_from_build!(build)
......@@ -150,9 +150,9 @@ RSpec.describe Ci::PendingBuild do
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
stub_feature_flags(ci_pending_builds_maintain_shared_runners_data: false)
stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end
it 'sets instance_runners_enabled to false' do
......@@ -168,7 +168,7 @@ RSpec.describe Ci::PendingBuild do
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
described_class.upsert_from_build!(build)
......@@ -176,9 +176,9 @@ RSpec.describe Ci::PendingBuild do
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
stub_feature_flags(ci_pending_builds_maintain_tags_data: false)
stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end
it 'does not set tag_ids' do
......
......@@ -43,9 +43,9 @@ RSpec.describe Ci::UpdatePendingBuildService do
expect(pending_build_2.instance_runners_enabled).to be_truthy
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
stub_feature_flags(ci_pending_builds_maintain_shared_runners_data: false)
stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end
it 'does not update all pending builds', :aggregate_failures do
......@@ -67,9 +67,9 @@ RSpec.describe Ci::UpdatePendingBuildService do
expect(pending_build_2.instance_runners_enabled).to be_truthy
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
stub_feature_flags(ci_pending_builds_maintain_shared_runners_data: false)
stub_feature_flags(ci_pending_builds_maintain_denormalized_data: false)
end
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