Commit 11d49cd2 authored by Francisco Javier López's avatar Francisco Javier López Committed by Dylan Griffith

Enable Runner ancestor scopes

parent 6b591ca2
......@@ -81,14 +81,7 @@ module Ci
scope :belonging_to_group, -> (group_id, include_ancestors: false) {
groups = ::Group.where(id: group_id)
if include_ancestors
groups = if Feature.enabled?(:linear_runner_ancestor_scopes, default_enabled: :yaml)
groups.self_and_ancestors
else
Gitlab::ObjectHierarchy.new(groups).base_and_ancestors
end
end
groups = groups.self_and_ancestors if include_ancestors
joins(:runner_namespaces)
.where(ci_runner_namespaces: { namespace_id: groups })
......@@ -109,14 +102,9 @@ module Ci
scope :belonging_to_parent_group_of_project, -> (project_id) {
project_groups = ::Group.joins(:projects).where(projects: { id: project_id })
hierarchy_groups = if Feature.enabled?(:linear_runner_ancestor_scopes, default_enabled: :yaml)
project_groups.self_and_ancestors.as_ids
else
Gitlab::ObjectHierarchy.new(project_groups).base_and_ancestors
end
joins(:groups)
.where(namespaces: { id: hierarchy_groups })
.where(namespaces: { id: project_groups.self_and_ancestors.as_ids })
.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/336433')
}
......
---
name: linear_runner_ancestor_scopes
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70385
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/341114
milestone: '14.6'
type: development
group: group::access
default_enabled: false
......@@ -204,7 +204,6 @@ RSpec.describe Ci::Runner do
end
describe '.belonging_to_parent_group_of_project' do
shared_examples 'returns parent group project runners' do
let(:project) { create(:project, group: group) }
let(:group) { create(:group) }
let(:runner) { create(:ci_runner, :group, groups: [group]) }
......@@ -228,17 +227,6 @@ RSpec.describe Ci::Runner do
end
end
it_behaves_like 'returns parent group project runners'
context 'when feature flag :linear_runner_ancestor_scopes is disabled' do
before do
stub_feature_flags(linear_runner_ancestor_scopes: false)
end
it_behaves_like 'returns parent group project runners'
end
end
describe '.owned_or_instance_wide' do
it 'returns a globally shared, a project specific and a group specific runner' do
# group specific
......
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