Commit 47beb008 authored by Alper Akgun's avatar Alper Akgun

Merge branch 'refactor-qutoa-cte-to-joins' into 'master'

Refactor CTE part of big query to joins [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!56760
parents dcf9fd4e d58b3767
......@@ -74,8 +74,14 @@ module EE
# rubocop: disable CodeReuse/ActiveRecord
def all_namespaces
namespaces = ::Namespace.reorder(nil).where('namespaces.id = projects.namespace_id')
::Gitlab::ObjectHierarchy.new(namespaces, options: { skip_ordering: true }).roots
if traversal_ids_enabled?
::Namespace
.where('namespaces.id = project_namespaces.traversal_ids[1]')
.joins('INNER JOIN namespaces as project_namespaces ON project_namespaces.id = projects.namespace_id')
else
namespaces = ::Namespace.reorder(nil).where('namespaces.id = projects.namespace_id')
::Gitlab::ObjectHierarchy.new(namespaces, options: { skip_ordering: true }).roots
end
end
# rubocop: enable CodeReuse/ActiveRecord
......@@ -87,6 +93,11 @@ module EE
ENV['DISABLE_SHARED_RUNNER_BUILD_MINUTES_LIMIT'].to_s != 'true'
end
def traversal_ids_enabled?
::Feature.enabled?(:sync_traversal_ids, default_enabled: :yaml) &&
::Feature.enabled?(:traversal_ids_for_quota_calculation, type: :development, default_enabled: :yaml)
end
override :pre_assign_runner_checks
def pre_assign_runner_checks
super.merge({
......
---
name: traversal_ids_for_quota_calculation
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56760
rollout_issue_url:
milestone: "13.11"
type: development
group: group::continuous integration
default_enabled: false
......@@ -46,7 +46,22 @@ RSpec.describe Ci::RegisterJobService do
shared_runners_seconds: runners_minutes_used * 60)
end
it { is_expected.to be_kind_of(Ci::Build) }
context 'with flags enabled' do
before do
stub_feature_flags(sync_traversal_ids: true)
stub_feature_flags(traversal_ids_for_quota_calculation: true)
end
it { is_expected.to be_kind_of(Ci::Build) }
end
context 'with flag disabled' do
before do
stub_feature_flags(traversal_ids_for_quota_calculation: false)
end
it { is_expected.to be_kind_of(Ci::Build) }
end
end
shared_examples 'does not return a build' do |runners_minutes_used|
......@@ -55,7 +70,22 @@ RSpec.describe Ci::RegisterJobService do
shared_runners_seconds: runners_minutes_used * 60)
end
it { is_expected.to be_nil }
context 'with flags enabled' do
before do
stub_feature_flags(sync_traversal_ids: true)
stub_feature_flags(traversal_ids_for_quota_calculation: true)
end
it { is_expected.to be_nil }
end
context 'with flag disabled' do
before do
stub_feature_flags(traversal_ids_for_quota_calculation: false)
end
it { is_expected.to be_nil }
end
end
context 'when limit set at global level' 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