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 ...@@ -24,7 +24,7 @@ module Ci
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def builds_for_group_runner def builds_for_group_runner
if strategy.use_denormalized_namespace_traversal_ids? if strategy.use_denormalized_data_strategy?
strategy.builds_for_group_runner strategy.builds_for_group_runner
else else
# Workaround for weird Rails bug, that makes `runner.groups.to_sql` to return `runner_id = NULL` # Workaround for weird Rails bug, that makes `runner.groups.to_sql` to return `runner_id = NULL`
......
...@@ -57,15 +57,7 @@ module Ci ...@@ -57,15 +57,7 @@ module Ci
relation.pluck(:id) relation.pluck(:id)
end end
def use_denormalized_shared_runners_data? def use_denormalized_data_strategy?
false
end
def use_denormalized_minutes_data?
false
end
def use_denormalized_namespace_traversal_ids?
false false
end end
......
...@@ -23,7 +23,7 @@ module Ci ...@@ -23,7 +23,7 @@ module Ci
end end
def builds_matching_tag_ids(relation, ids) 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) relation.for_tags(runner.tags_ids)
else else
relation.merge(CommitStatus.matches_tag_ids(ids, table: 'ci_pending_builds', column: 'build_id')) relation.merge(CommitStatus.matches_tag_ids(ids, table: 'ci_pending_builds', column: 'build_id'))
...@@ -31,7 +31,7 @@ module Ci ...@@ -31,7 +31,7 @@ module Ci
end end
def builds_with_any_tags(relation) 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') relation.where('cardinality(tag_ids) > 0')
else else
relation.merge(CommitStatus.with_any_tags(table: 'ci_pending_builds', column: 'build_id')) relation.merge(CommitStatus.with_any_tags(table: 'ci_pending_builds', column: 'build_id'))
...@@ -50,22 +50,14 @@ module Ci ...@@ -50,22 +50,14 @@ module Ci
relation.pluck(:build_id) relation.pluck(:build_id)
end end
def use_denormalized_shared_runners_data? def use_denormalized_data_strategy?
::Feature.enabled?(:ci_queueing_denormalize_shared_runners_information, runner, type: :development, default_enabled: :yaml) ::Feature.enabled?(:ci_queuing_use_denormalized_data_strategy, 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)
end end
private private
def builds_available_for_shared_runners def builds_available_for_shared_runners
if use_denormalized_shared_runners_data? if use_denormalized_data_strategy?
new_builds.with_instance_runners new_builds.with_instance_runners
else else
new_builds 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 name: ci_queuing_use_denormalized_data_strategy
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65648 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76543
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338366 rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/332951
milestone: '14.1' milestone: '14.6'
type: development type: development
group: group::pipeline execution group: group::pipeline execution
default_enabled: false default_enabled: true
...@@ -19,7 +19,7 @@ module EE ...@@ -19,7 +19,7 @@ module EE
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def enforce_minutes_based_on_cost_factors(relation) 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) strategy.enforce_minutes_quota(relation)
else else
enforce_minutes_using_legacy_data(relation) enforce_minutes_using_legacy_data(relation)
...@@ -27,7 +27,7 @@ module EE ...@@ -27,7 +27,7 @@ module EE
end end
def enforce_minutes_using_legacy_data(relation) 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 # 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 # 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 ...@@ -43,17 +43,17 @@ RSpec.describe Ci::RegisterJobService, '#execute' do
is_expected.to be_kind_of(Ci::Build) is_expected.to be_kind_of(Ci::Build)
end end
context 'with ci_queueing_denormalize_ci_minutes_information enabled' do context 'with ci_queuing_use_denormalized_data_strategy enabled' do
before do before do
stub_feature_flags(ci_queueing_denormalize_ci_minutes_information: true) stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true)
end end
it { is_expected.to be_kind_of(Ci::Build) } it { is_expected.to be_kind_of(Ci::Build) }
end end
context 'with ci_queueing_denormalize_ci_minutes_information disabled' do context 'with ci_queuing_use_denormalized_data_strategy disabled' do
before do before do
stub_feature_flags(ci_queueing_denormalize_ci_minutes_information: false) stub_feature_flags(ci_queuing_use_denormalized_data_strategy: false)
end end
around do |example| around do |example|
...@@ -96,17 +96,17 @@ RSpec.describe Ci::RegisterJobService, '#execute' do ...@@ -96,17 +96,17 @@ RSpec.describe Ci::RegisterJobService, '#execute' do
is_expected.to be_kind_of(Ci::Build) is_expected.to be_kind_of(Ci::Build)
end end
context 'with ci_queueing_denormalize_ci_minutes_information enabled' do context 'with ci_queuing_use_denormalized_data_strategy enabled' do
before do before do
stub_feature_flags(ci_queueing_denormalize_ci_minutes_information: true) stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true)
end end
it { is_expected.to be_nil } it { is_expected.to be_nil }
end end
context 'with ci_queueing_denormalize_ci_minutes_information disabled' do context 'with ci_queuing_use_denormalized_data_strategy disabled' do
before do before do
stub_feature_flags(ci_queueing_denormalize_ci_minutes_information: false) stub_feature_flags(ci_queuing_use_denormalized_data_strategy: false)
end end
around do |example| around do |example|
...@@ -332,17 +332,17 @@ RSpec.describe Ci::RegisterJobService, '#execute' do ...@@ -332,17 +332,17 @@ RSpec.describe Ci::RegisterJobService, '#execute' do
stub_feature_flags(ci_pending_builds_queue_source: true) stub_feature_flags(ci_pending_builds_queue_source: true)
end end
context 'with ci_queueing_denormalize_shared_runners_information enabled' do context 'with ci_queuing_use_denormalized_data_strategy enabled' do
before do before do
stub_feature_flags(ci_queueing_denormalize_shared_runners_information: true) stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true)
end end
include_examples 'namespace minutes quota' include_examples 'namespace minutes quota'
end end
context 'with ci_queueing_denormalize_shared_runners_information disabled' do context 'with ci_queuing_use_denormalized_data_strategy disabled' do
before do before do
stub_feature_flags(ci_queueing_denormalize_shared_runners_information: false) stub_feature_flags(ci_queuing_use_denormalized_data_strategy: false)
end end
around do |example| around do |example|
......
...@@ -740,17 +740,17 @@ module Ci ...@@ -740,17 +740,17 @@ module Ci
stub_feature_flags(ci_pending_builds_queue_source: true) stub_feature_flags(ci_pending_builds_queue_source: true)
end end
context 'with ci_queueing_denormalize_shared_runners_information enabled' do context 'with ci_queuing_use_denormalized_data_strategy enabled' do
before do before do
stub_feature_flags(ci_queueing_denormalize_shared_runners_information: true) stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true)
end end
include_examples 'handles runner assignment' include_examples 'handles runner assignment'
end end
context 'with ci_queueing_denormalize_shared_runners_information disabled' do context 'with ci_queuing_use_denormalized_data_strategy disabled' do
before do before do
stub_feature_flags(ci_queueing_denormalize_shared_runners_information: false) stub_feature_flags(ci_queuing_use_denormalized_data_strategy: false)
end end
around do |example| around do |example|
...@@ -762,37 +762,9 @@ module Ci ...@@ -762,37 +762,9 @@ module Ci
include_examples 'handles runner assignment' include_examples 'handles runner assignment'
end end
context 'with ci_queueing_denormalize_tags_information enabled' do context 'with ci_queuing_use_denormalized_data_strategy enabled' do
before do before do
stub_feature_flags(ci_queueing_denormalize_tags_information: true) stub_feature_flags(ci_queuing_use_denormalized_data_strategy: 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
end end
include_examples 'handles runner assignment' 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