Commit 0efa349c authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'ci_merge_denormalize_queue_flags' into 'master'

Merge CI queuing denormalization feature flags into a single one

See merge request gitlab-org/gitlab!76543
parents 4da5e56d 78556e3f
......@@ -24,7 +24,7 @@ module Ci
# rubocop:disable CodeReuse/ActiveRecord
def builds_for_group_runner
if strategy.use_denormalized_namespace_traversal_ids?
if strategy.use_denormalized_data_strategy?
strategy.builds_for_group_runner
else
# Workaround for weird Rails bug, that makes `runner.groups.to_sql` to return `runner_id = NULL`
......
......@@ -57,15 +57,7 @@ module Ci
relation.pluck(:id)
end
def use_denormalized_shared_runners_data?
false
end
def use_denormalized_minutes_data?
false
end
def use_denormalized_namespace_traversal_ids?
def use_denormalized_data_strategy?
false
end
......
......@@ -23,7 +23,7 @@ module Ci
end
def builds_matching_tag_ids(relation, ids)
if ::Feature.enabled?(:ci_queueing_denormalize_tags_information, runner, default_enabled: :yaml)
if use_denormalized_data_strategy?
relation.for_tags(runner.tags_ids)
else
relation.merge(CommitStatus.matches_tag_ids(ids, table: 'ci_pending_builds', column: 'build_id'))
......@@ -31,7 +31,7 @@ module Ci
end
def builds_with_any_tags(relation)
if ::Feature.enabled?(:ci_queueing_denormalize_tags_information, runner, default_enabled: :yaml)
if use_denormalized_data_strategy?
relation.where('cardinality(tag_ids) > 0')
else
relation.merge(CommitStatus.with_any_tags(table: 'ci_pending_builds', column: 'build_id'))
......@@ -50,22 +50,14 @@ module Ci
relation.pluck(:build_id)
end
def use_denormalized_shared_runners_data?
::Feature.enabled?(:ci_queueing_denormalize_shared_runners_information, runner, type: :development, default_enabled: :yaml)
end
def use_denormalized_minutes_data?
::Feature.enabled?(:ci_queueing_denormalize_ci_minutes_information, runner, type: :development, default_enabled: :yaml)
end
def use_denormalized_namespace_traversal_ids?
::Feature.enabled?(:ci_queueing_denormalize_namespace_traversal_ids, runner, type: :development, default_enabled: :yaml)
def use_denormalized_data_strategy?
::Feature.enabled?(:ci_queuing_use_denormalized_data_strategy, default_enabled: :yaml)
end
private
def builds_available_for_shared_runners
if use_denormalized_shared_runners_data?
if use_denormalized_data_strategy?
new_builds.with_instance_runners
else
new_builds
......
---
name: ci_queueing_denormalize_ci_minutes_information
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66962
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338290
milestone: '14.2'
type: development
group: 'group::pipeline execution'
default_enabled: false
---
name: ci_queueing_denormalize_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_queueing_denormalize_shared_runners_information
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66082
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338289
milestone: '14.2'
type: development
group: group::pipeline execution
default_enabled: false
---
name: ci_queueing_denormalize_tags_information
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65648
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338366
milestone: '14.1'
name: ci_queuing_use_denormalized_data_strategy
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76543
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
......@@ -19,7 +19,7 @@ module EE
# rubocop: disable CodeReuse/ActiveRecord
def enforce_minutes_based_on_cost_factors(relation)
if strategy.use_denormalized_minutes_data?
if strategy.use_denormalized_data_strategy?
strategy.enforce_minutes_quota(relation)
else
enforce_minutes_using_legacy_data(relation)
......@@ -27,7 +27,7 @@ module EE
end
def enforce_minutes_using_legacy_data(relation)
if strategy.use_denormalized_shared_runners_data?
if strategy.use_denormalized_data_strategy?
# If shared runners information is denormalized then the query does not include the join
# with `projects` anymore, so we need to add it until we use denormalized ci minutes
......
......@@ -43,17 +43,17 @@ RSpec.describe Ci::RegisterJobService, '#execute' do
is_expected.to be_kind_of(Ci::Build)
end
context 'with ci_queueing_denormalize_ci_minutes_information enabled' do
context 'with ci_queuing_use_denormalized_data_strategy enabled' do
before do
stub_feature_flags(ci_queueing_denormalize_ci_minutes_information: true)
stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true)
end
it { is_expected.to be_kind_of(Ci::Build) }
end
context 'with ci_queueing_denormalize_ci_minutes_information disabled' do
context 'with ci_queuing_use_denormalized_data_strategy disabled' do
before do
stub_feature_flags(ci_queueing_denormalize_ci_minutes_information: false)
stub_feature_flags(ci_queuing_use_denormalized_data_strategy: false)
end
around do |example|
......@@ -96,17 +96,17 @@ RSpec.describe Ci::RegisterJobService, '#execute' do
is_expected.to be_kind_of(Ci::Build)
end
context 'with ci_queueing_denormalize_ci_minutes_information enabled' do
context 'with ci_queuing_use_denormalized_data_strategy enabled' do
before do
stub_feature_flags(ci_queueing_denormalize_ci_minutes_information: true)
stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true)
end
it { is_expected.to be_nil }
end
context 'with ci_queueing_denormalize_ci_minutes_information disabled' do
context 'with ci_queuing_use_denormalized_data_strategy disabled' do
before do
stub_feature_flags(ci_queueing_denormalize_ci_minutes_information: false)
stub_feature_flags(ci_queuing_use_denormalized_data_strategy: false)
end
around do |example|
......@@ -332,17 +332,17 @@ RSpec.describe Ci::RegisterJobService, '#execute' do
stub_feature_flags(ci_pending_builds_queue_source: true)
end
context 'with ci_queueing_denormalize_shared_runners_information enabled' do
context 'with ci_queuing_use_denormalized_data_strategy enabled' do
before do
stub_feature_flags(ci_queueing_denormalize_shared_runners_information: true)
stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true)
end
include_examples 'namespace minutes quota'
end
context 'with ci_queueing_denormalize_shared_runners_information disabled' do
context 'with ci_queuing_use_denormalized_data_strategy disabled' do
before do
stub_feature_flags(ci_queueing_denormalize_shared_runners_information: false)
stub_feature_flags(ci_queuing_use_denormalized_data_strategy: false)
end
around do |example|
......
......@@ -740,17 +740,17 @@ module Ci
stub_feature_flags(ci_pending_builds_queue_source: true)
end
context 'with ci_queueing_denormalize_shared_runners_information enabled' do
context 'with ci_queuing_use_denormalized_data_strategy enabled' do
before do
stub_feature_flags(ci_queueing_denormalize_shared_runners_information: true)
stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true)
end
include_examples 'handles runner assignment'
end
context 'with ci_queueing_denormalize_shared_runners_information disabled' do
context 'with ci_queuing_use_denormalized_data_strategy disabled' do
before do
stub_feature_flags(ci_queueing_denormalize_shared_runners_information: false)
stub_feature_flags(ci_queuing_use_denormalized_data_strategy: false)
end
around do |example|
......@@ -762,37 +762,9 @@ module Ci
include_examples 'handles runner assignment'
end
context 'with ci_queueing_denormalize_tags_information enabled' do
context 'with ci_queuing_use_denormalized_data_strategy enabled' do
before do
stub_feature_flags(ci_queueing_denormalize_tags_information: true)
end
include_examples 'handles runner assignment'
end
context 'with ci_queueing_denormalize_tags_information disabled' do
before do
stub_feature_flags(ci_queueing_denormalize_tags_information: false)
end
around do |example|
allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/332952') do
example.run
end
end
include_examples 'handles runner assignment'
end
context 'with ci_queueing_denormalize_namespace_traversal_ids disabled' do
before do
stub_feature_flags(ci_queueing_denormalize_namespace_traversal_ids: false)
end
around do |example|
allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/332952') do
example.run
end
stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true)
end
include_examples 'handles runner assignment'
......
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