Commit 14196db4 authored by Alessio Caiazza's avatar Alessio Caiazza

Remove shared_runner_minutes_on_root_namespace FF

Removing this feature flag NamespaceStatistcs will be aggregated on
root-namespace matching gitlab.com billing schema
parent 7521ec8d
...@@ -7,19 +7,11 @@ class Groups::PipelineQuotaController < Groups::ApplicationController ...@@ -7,19 +7,11 @@ class Groups::PipelineQuotaController < Groups::ApplicationController
layout 'group_settings' layout 'group_settings'
def index def index
@projects = all_projects.with_shared_runners_limit_enabled.page(params[:page]) @projects = @group.all_projects.with_shared_runners_limit_enabled.page(params[:page])
end end
private private
def all_projects
if ::Feature.enabled?(:shared_runner_minutes_on_root_namespace)
@group.all_projects
else
@group.projects
end
end
def validate_shared_runner_minutes_support! def validate_shared_runner_minutes_support!
render_404 unless @group.shared_runner_minutes_supported? render_404 unless @group.shared_runner_minutes_supported?
end end
......
...@@ -154,11 +154,7 @@ module EE ...@@ -154,11 +154,7 @@ module EE
end end
def shared_runner_minutes_supported? def shared_runner_minutes_supported?
if has_parent? !has_parent?
!::Feature.enabled?(:shared_runner_minutes_on_root_namespace)
else
true
end
end end
def actual_shared_runners_minutes_limit(include_extra: true) def actual_shared_runners_minutes_limit(include_extra: true)
...@@ -189,11 +185,7 @@ module EE ...@@ -189,11 +185,7 @@ module EE
end end
def shared_runners_enabled? def shared_runners_enabled?
if ::Feature.enabled?(:shared_runner_minutes_on_root_namespace)
all_projects.with_shared_runners.any? all_projects.with_shared_runners.any?
else
projects.with_shared_runners.any?
end
end end
# These helper methods are required to not break the Namespace API. # These helper methods are required to not break the Namespace API.
......
...@@ -166,11 +166,7 @@ module EE ...@@ -166,11 +166,7 @@ module EE
end end
def shared_runners_limit_namespace def shared_runners_limit_namespace
if ::Feature.enabled?(:shared_runner_minutes_on_root_namespace)
root_namespace root_namespace
else
namespace
end
end end
def mirror def mirror
......
...@@ -51,12 +51,7 @@ module EE ...@@ -51,12 +51,7 @@ module EE
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def all_namespaces def all_namespaces
namespaces = ::Namespace.reorder(nil).where('namespaces.id = projects.namespace_id') namespaces = ::Namespace.reorder(nil).where('namespaces.id = projects.namespace_id')
::Gitlab::ObjectHierarchy.new(namespaces).roots
if ::Feature.enabled?(:shared_runner_minutes_on_root_namespace)
namespaces = ::Gitlab::ObjectHierarchy.new(namespaces).roots
end
namespaces
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
---
title: Remove shared_runner_minutes_on_root_namespace feature flag
merge_request: 13208
author:
type: changed
...@@ -101,30 +101,6 @@ describe 'Groups > Pipeline Quota' do ...@@ -101,30 +101,6 @@ describe 'Groups > Pipeline Quota' do
end end
end end
context 'with shared_runner_minutes_on_root_namespace disabled' do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end
context 'when accessing group with subgroups' do
let(:group) { create(:group, :with_used_build_minutes_limit) }
let!(:subgroup) { create(:group, parent: group) }
let!(:subproject) { create(:project, namespace: subgroup, shared_runners_enabled: true) }
it 'does not show project of subgroup' do
visit_pipeline_quota_page
expect(page).to have_content(project.full_name)
expect(page).not_to have_content(subproject.full_name)
end
end
end
context 'with shared_runner_minutes_on_root_namespace enabled', :nested_groups do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end
context 'when accessing subgroup' do context 'when accessing subgroup' do
let(:root_ancestor) { create(:group) } let(:root_ancestor) { create(:group) }
let(:group) { create(:group, parent: root_ancestor) } let(:group) { create(:group, parent: root_ancestor) }
...@@ -147,7 +123,6 @@ describe 'Groups > Pipeline Quota' do ...@@ -147,7 +123,6 @@ describe 'Groups > Pipeline Quota' do
expect(page).to have_content(subproject.full_name) expect(page).to have_content(subproject.full_name)
end end
end end
end
def visit_pipeline_quota_page def visit_pipeline_quota_page
visit group_pipeline_quota_path(group) visit group_pipeline_quota_path(group)
......
...@@ -99,10 +99,6 @@ describe Namespace do ...@@ -99,10 +99,6 @@ describe Namespace do
end end
describe '#validate_shared_runner_minutes_support' do describe '#validate_shared_runner_minutes_support' do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end
context 'when changing :shared_runners_minutes_limit' do context 'when changing :shared_runners_minutes_limit' do
before do before do
namespace.shared_runners_minutes_limit = 100 namespace.shared_runners_minutes_limit = 100
...@@ -431,26 +427,10 @@ describe Namespace do ...@@ -431,26 +427,10 @@ describe Namespace do
namespace.parent = build(:group) namespace.parent = build(:group)
end end
context 'when shared_runner_minutes_on_root_namespace is disabled' do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end
it 'returns true' do
is_expected.to eq(true)
end
end
context 'when shared_runner_minutes_on_root_namespace is enabled', :nested_groups do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end
it 'returns false' do it 'returns false' do
is_expected.to eq(false) is_expected.to eq(false)
end end
end end
end
context 'when is root' do context 'when is root' do
it 'returns true' do it 'returns true' do
...@@ -482,7 +462,6 @@ describe Namespace do ...@@ -482,7 +462,6 @@ describe Namespace do
context 'when is subgroup', :nested_groups do context 'when is subgroup', :nested_groups do
before do before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
namespace.parent = build(:group) namespace.parent = build(:group)
end end
...@@ -499,30 +478,14 @@ describe Namespace do ...@@ -499,30 +478,14 @@ describe Namespace do
describe '#shared_runners_enabled?' do describe '#shared_runners_enabled?' do
subject { namespace.shared_runners_enabled? } subject { namespace.shared_runners_enabled? }
context 'subgroup with shared runners enabled project' do context 'subgroup with shared runners enabled project', :nested_groups do
let(:subgroup) { create(:group, parent: namespace) } let(:subgroup) { create(:group, parent: namespace) }
let!(:subproject) { create(:project, namespace: subgroup, shared_runners_enabled: true) } let!(:subproject) { create(:project, namespace: subgroup, shared_runners_enabled: true) }
context 'when shared_runner_minutes_on_root_namespace is disabled' do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end
it "returns false" do
is_expected.to eq(false)
end
end
context 'when shared_runner_minutes_on_root_namespace is enabled', :nested_groups do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end
it "returns true" do it "returns true" do
is_expected.to eq(true) is_expected.to eq(true)
end end
end end
end
context 'group with shared runners enabled project' do context 'group with shared runners enabled project' do
let!(:project) { create(:project, namespace: namespace, shared_runners_enabled: true) } let!(:project) { create(:project, namespace: namespace, shared_runners_enabled: true) }
......
...@@ -620,26 +620,10 @@ describe Project do ...@@ -620,26 +620,10 @@ describe Project do
subject { project.shared_runners_limit_namespace } subject { project.shared_runners_limit_namespace }
context 'when shared_runner_minutes_on_root_namespace is disabled' do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end
it 'returns parent namespace' do
is_expected.to eq(group)
end
end
context 'when shared_runner_minutes_on_root_namespace is enabled', :nested_groups do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end
it 'returns root namespace' do it 'returns root namespace' do
is_expected.to eq(root_ancestor) is_expected.to eq(root_ancestor)
end end
end end
end
describe '#shared_runners_minutes_limit_enabled?' do describe '#shared_runners_minutes_limit_enabled?' do
let(:project) { create(:project) } let(:project) { create(:project) }
......
...@@ -86,38 +86,12 @@ describe Ci::RegisterJobService do ...@@ -86,38 +86,12 @@ describe Ci::RegisterJobService do
end end
end end
context 'when group is subgroup' do context 'when group is subgroup', :nested_groups do
let!(:root_ancestor) { create(:group) } let!(:root_ancestor) { create(:group) }
let!(:group) { create(:group, parent: root_ancestor) } let!(:group) { create(:group, parent: root_ancestor) }
let!(:project) { create :project, shared_runners_enabled: true, group: group } let!(:project) { create :project, shared_runners_enabled: true, group: group }
let(:build) { execute(shared_runner) } let(:build) { execute(shared_runner) }
context 'when shared_runner_minutes_on_root_namespace is disabled' do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end
it "does return a build" do
expect(build).not_to be_nil
end
context 'when we are over limit on subnamespace' do
before do
group.create_namespace_statistics(
shared_runners_seconds: 6001)
end
it "does not return a build" do
expect(build).to be_nil
end
end
end
context 'when shared_runner_minutes_on_root_namespace is enabled', :nested_groups do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end
it "does return a build" do it "does return a build" do
expect(build).not_to be_nil expect(build).not_to be_nil
end end
...@@ -145,7 +119,6 @@ describe Ci::RegisterJobService do ...@@ -145,7 +119,6 @@ describe Ci::RegisterJobService do
end end
end end
end end
end
context 'for project with shared runners when limit is set only on namespace' do context 'for project with shared runners when limit is set only on namespace' do
let(:build) { execute(shared_runner) } let(:build) { execute(shared_runner) }
......
...@@ -43,31 +43,10 @@ describe UpdateBuildMinutesService do ...@@ -43,31 +43,10 @@ describe UpdateBuildMinutesService do
end end
end end
context 'when namespace is subgroup' do context 'when namespace is subgroup', :nested_groups do
let(:root_ancestor) { create(:group, shared_runners_minutes_limit: 100) } let(:root_ancestor) { create(:group, shared_runners_minutes_limit: 100) }
context 'when shared_runner_minutes_on_root_namespace is disabled' do
let(:namespace) { create(:namespace, parent: root_ancestor, shared_runners_minutes_limit: 100) }
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end
it 'creates a statistics in current namespace' do
subject
expect(namespace.namespace_statistics.reload.shared_runners_seconds)
.to eq(build.duration.to_i)
end
end
context 'when shared_runner_minutes_on_root_namespace is enabled', :nested_groups do
let(:namespace) { create(:namespace, parent: root_ancestor) } let(:namespace) { create(:namespace, parent: root_ancestor) }
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end
it 'creates a statistics in root namespace' do it 'creates a statistics in root namespace' do
subject subject
...@@ -76,7 +55,6 @@ describe UpdateBuildMinutesService do ...@@ -76,7 +55,6 @@ describe UpdateBuildMinutesService do
end end
end end
end end
end
context 'for specific runner' do context 'for specific runner' do
let(:runner) { create(:ci_runner, :project) } let(:runner) { create(:ci_runner, :project) }
......
...@@ -10,29 +10,7 @@ describe 'admin/groups/_form' do ...@@ -10,29 +10,7 @@ describe 'admin/groups/_form' do
allow(view).to receive(:visibility_level) { group.visibility_level } allow(view).to receive(:visibility_level) { group.visibility_level }
end end
describe 'when :shared_runner_minutes_on_root_namespace is disabled' do context 'when sub group is used', :nested_groups do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: false)
end
context 'when sub group is used' do
let(:root_ancestor) { create(:group) }
let(:group) { build(:group, parent: root_ancestor) }
it 'renders shared_runners_minutes_setting' do
render
expect(rendered).to render_template('namespaces/_shared_runners_minutes_setting')
end
end
end
describe 'when :shared_runner_minutes_on_root_namespace is enabled', :nested_groups do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end
context 'when sub group is used' do
let(:root_ancestor) { create(:group) } let(:root_ancestor) { create(:group) }
let(:group) { build(:group, parent: root_ancestor) } let(:group) { build(:group, parent: root_ancestor) }
...@@ -52,5 +30,4 @@ describe 'admin/groups/_form' do ...@@ -52,5 +30,4 @@ describe 'admin/groups/_form' do
expect(rendered).to render_template('namespaces/_shared_runners_minutes_setting') expect(rendered).to render_template('namespaces/_shared_runners_minutes_setting')
end end
end end
end
end end
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