Commit 31ea7607 authored by Furkan Ayhan's avatar Furkan Ayhan Committed by Adam Hegyi

Remove the FF ci_find_runners_by_ci_mirrors

This also removes some legacy codes and cross join allows.

Changelog: other
parent 34760e19
......@@ -9,11 +9,9 @@ class Groups::RunnersController < Groups::ApplicationController
feature_category :runner
def index
::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/336433') do
finder = Ci::RunnersFinder.new(current_user: current_user, params: { group: @group })
@group_runners_limited_count = finder.execute.except(:limit, :offset).page.total_count_with_limit(:all, limit: 1000)
end
end
def runner_list_group_view_vue_ui_enabled
render_404 unless Feature.enabled?(:runner_list_group_view_vue_ui, group, default_enabled: :yaml)
......@@ -62,12 +60,10 @@ class Groups::RunnersController < Groups::ApplicationController
private
def runner
::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/336433') do
@runner ||= Ci::RunnersFinder.new(current_user: current_user, params: { group: @group }).execute
.except(:limit, :offset)
.find(params[:id])
end
end
def runner_params
params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
......
......@@ -23,11 +23,6 @@ module Groups
@group_runners = runners_finder.execute.page(params[:page]).per(NUMBER_OF_RUNNERS_PER_PAGE)
@sort = runners_finder.sort_key
# Allow sql generated by the two relations above, @all_group_runners and @group_runners
::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/336433') do
render
end
end
def update
......
......@@ -53,13 +53,7 @@ module Ci
when :direct
Ci::Runner.belonging_to_group(@group.id)
when :descendants, nil
if ::Feature.enabled?(:ci_find_runners_by_ci_mirrors, @group, default_enabled: :yaml)
Ci::Runner.belonging_to_group_or_project_descendants(@group.id)
else
# Getting all runners from the group itself and all its descendant groups/projects
descendant_projects = Project.for_group_and_its_subgroups(@group)
Ci::Runner.legacy_belonging_to_group_or_project(@group.self_and_descendants, descendant_projects)
end
else
raise ArgumentError, 'Invalid membership filter'
end
......
......@@ -119,30 +119,6 @@ module Ci
.where(ci_runner_namespaces: { namespace_id: group_self_and_ancestors_ids })
}
# deprecated
# split this into: belonging_to_group & belonging_to_group_and_ancestors
scope :legacy_belonging_to_group, -> (group_id, include_ancestors: false) {
groups = ::Group.where(id: group_id)
groups = groups.self_and_ancestors if include_ancestors
joins(:runner_namespaces)
.where(ci_runner_namespaces: { namespace_id: groups })
.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/336433')
}
# deprecated
scope :legacy_belonging_to_group_or_project, -> (group_id, project_id) {
groups = ::Group.where(id: group_id)
group_runners = joins(:runner_namespaces).where(ci_runner_namespaces: { namespace_id: groups })
project_runners = joins(:runner_projects).where(ci_runner_projects: { project_id: project_id })
union_sql = ::Gitlab::SQL::Union.new([group_runners, project_runners]).to_sql
from("(#{union_sql}) #{table_name}")
.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/336433')
}
scope :belonging_to_parent_group_of_project, -> (project_id) {
raise ArgumentError, "only 1 project_id allowed for performance reasons" unless project_id.is_a?(Integer)
......@@ -165,16 +141,9 @@ module Ci
end
scope :group_or_instance_wide, -> (group) do
group_and_ancestor_runners =
if ::Feature.enabled?(:ci_find_runners_by_ci_mirrors, group, default_enabled: :yaml)
belonging_to_group_and_ancestors(group.id)
else
legacy_belonging_to_group(group.id, include_ancestors: true)
end
from_union(
[
group_and_ancestor_runners,
belonging_to_group_and_ancestors(group.id),
group.shared_runners
],
remove_duplicates: false
......
---
name: ci_find_runners_by_ci_mirrors
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74900
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/347226
milestone: '14.7'
type: development
group: group::runner
default_enabled: false
......@@ -61,13 +61,7 @@ module Analytics
# rubocop: enable CodeReuse/ActiveRecord
def runner_configured
if ::Feature.enabled?(:ci_find_runners_by_ci_mirrors, enabled_namespace.namespace, default_enabled: :yaml)
Ci::Runner.active.belonging_to_group_or_project_descendants(enabled_namespace.namespace.id).exists?
else
::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/337541') do
Ci::Runner.active.legacy_belonging_to_group_or_project(snapshot_groups, snapshot_project_ids).exists?
end
end
end
def pipeline_succeeded
......
......@@ -61,7 +61,7 @@ RSpec.describe Analytics::DevopsAdoption::SnapshotCalculator do
it { is_expected.to eq false }
end
shared_examples 'runner_configured' do
describe 'runner_configured' do
subject { data[:runner_configured] }
let!(:inactive_runner) { create(:ci_runner, :project, active: false) }
......@@ -77,16 +77,6 @@ RSpec.describe Analytics::DevopsAdoption::SnapshotCalculator do
it { is_expected.to eq false }
end
it_behaves_like 'runner_configured'
context 'when the FF ci_find_runners_by_ci_mirrors is disabled' do
before do
stub_feature_flags(ci_find_runners_by_ci_mirrors: false)
end
it_behaves_like 'runner_configured'
end
describe 'pipeline_succeeded' do
subject { data[:pipeline_succeeded] }
......
......@@ -206,7 +206,7 @@ RSpec.describe Ci::RunnersFinder do
sub_group_4.runners << runner_sub_group_4
end
shared_examples '#execute' do
describe '#execute' do
subject { described_class.new(current_user: user, params: params).execute }
shared_examples 'membership equal to :descendants' do
......@@ -349,16 +349,6 @@ RSpec.describe Ci::RunnersFinder do
end
end
it_behaves_like '#execute'
context 'when the FF ci_find_runners_by_ci_mirrors is disabled' do
before do
stub_feature_flags(ci_find_runners_by_ci_mirrors: false)
end
it_behaves_like '#execute'
end
describe '#sort_key' do
subject { described_class.new(current_user: user, params: params.merge(group: group)).sort_key }
......
......@@ -1438,47 +1438,6 @@ RSpec.describe Ci::Runner do
it { is_expected.to eq(contacted_at_stored) }
end
describe '.legacy_belonging_to_group' do
shared_examples 'returns group runners' do
it 'returns the specific group runner' do
group = create(:group)
runner = create(:ci_runner, :group, groups: [group])
unrelated_group = create(:group)
create(:ci_runner, :group, groups: [unrelated_group])
expect(described_class.legacy_belonging_to_group(group.id)).to contain_exactly(runner)
end
context 'runner belonging to parent group' do
let_it_be(:parent_group) { create(:group) }
let_it_be(:parent_runner) { create(:ci_runner, :group, groups: [parent_group]) }
let_it_be(:group) { create(:group, parent: parent_group) }
context 'when include_parent option is passed' do
it 'returns the group runner from the parent group' do
expect(described_class.legacy_belonging_to_group(group.id, include_ancestors: true)).to contain_exactly(parent_runner)
end
end
context 'when include_parent option is not passed' do
it 'does not return the group runner from the parent group' do
expect(described_class.legacy_belonging_to_group(group.id)).to be_empty
end
end
end
end
it_behaves_like 'returns group 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 group runners'
end
end
describe '.belonging_to_group' do
it 'returns the specific group runner' do
group = create(:group)
......
......@@ -1020,7 +1020,7 @@ RSpec.describe API::Ci::Runners do
end
end
shared_context 'GET /groups/:id/runners' do
describe 'GET /groups/:id/runners' do
context 'authorized user with maintainer privileges' do
it 'returns all runners' do
get api("/groups/#{group.id}/runners", user)
......@@ -1108,16 +1108,6 @@ RSpec.describe API::Ci::Runners do
end
end
it_behaves_like 'GET /groups/:id/runners'
context 'when the FF ci_find_runners_by_ci_mirrors is disabled' do
before do
stub_feature_flags(ci_find_runners_by_ci_mirrors: false)
end
it_behaves_like 'GET /groups/:id/runners'
end
describe 'POST /projects/:id/runners' do
context 'authorized user' do
let_it_be(:project_runner2) { create(:ci_runner, :project, projects: [project2]) }
......
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