Commit d7d90eed authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'ac-remove-ff-shared_runner_minutes_on_root_namespace' into 'master'

Remove shared_runner_minutes_on_root_namespace feature flag

Closes #11675

See merge request gitlab-org/gitlab-ee!13208
parents 02d1f8ee 14196db4
......@@ -7,19 +7,11 @@ class Groups::PipelineQuotaController < Groups::ApplicationController
layout 'group_settings'
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
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!
render_404 unless @group.shared_runner_minutes_supported?
end
......
......@@ -154,11 +154,7 @@ module EE
end
def shared_runner_minutes_supported?
if has_parent?
!::Feature.enabled?(:shared_runner_minutes_on_root_namespace)
else
true
end
!has_parent?
end
def actual_shared_runners_minutes_limit(include_extra: true)
......@@ -189,11 +185,7 @@ module EE
end
def shared_runners_enabled?
if ::Feature.enabled?(:shared_runner_minutes_on_root_namespace)
all_projects.with_shared_runners.any?
else
projects.with_shared_runners.any?
end
all_projects.with_shared_runners.any?
end
# These helper methods are required to not break the Namespace API.
......
......@@ -166,11 +166,7 @@ module EE
end
def shared_runners_limit_namespace
if ::Feature.enabled?(:shared_runner_minutes_on_root_namespace)
root_namespace
else
namespace
end
root_namespace
end
def mirror
......
......@@ -51,12 +51,7 @@ module EE
# rubocop: disable CodeReuse/ActiveRecord
def all_namespaces
namespaces = ::Namespace.reorder(nil).where('namespaces.id = projects.namespace_id')
if ::Feature.enabled?(:shared_runner_minutes_on_root_namespace)
namespaces = ::Gitlab::ObjectHierarchy.new(namespaces).roots
end
namespaces
::Gitlab::ObjectHierarchy.new(namespaces).roots
end
# rubocop: enable CodeReuse/ActiveRecord
......
---
title: Remove shared_runner_minutes_on_root_namespace feature flag
merge_request: 13208
author:
type: changed
......@@ -101,51 +101,26 @@ describe 'Groups > Pipeline Quota' do
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) }
context 'when accessing subgroup' do
let(:root_ancestor) { create(:group) }
let(:group) { create(:group, parent: root_ancestor) }
it 'does not show project of subgroup' do
visit_pipeline_quota_page
it 'does not show subproject' do
visit_pipeline_quota_page
expect(page).to have_content(project.full_name)
expect(page).not_to have_content(subproject.full_name)
end
expect(page).to have_http_status(:not_found)
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
let(:root_ancestor) { create(:group) }
let(:group) { create(:group, parent: root_ancestor) }
it 'does not show subproject' do
visit_pipeline_quota_page
context 'when accesing root group' do
let!(:subgroup) { create(:group, parent: group) }
let!(:subproject) { create(:project, namespace: subgroup, shared_runners_enabled: true) }
expect(page).to have_http_status(:not_found)
end
end
context 'when accesing root group' do
let!(:subgroup) { create(:group, parent: group) }
let!(:subproject) { create(:project, namespace: subgroup, shared_runners_enabled: true) }
it 'does show projects of subgroup' do
visit_pipeline_quota_page
it 'does show projects of subgroup' do
visit_pipeline_quota_page
expect(page).to have_content(project.full_name)
expect(page).to have_content(subproject.full_name)
end
expect(page).to have_content(project.full_name)
expect(page).to have_content(subproject.full_name)
end
end
......
......@@ -99,10 +99,6 @@ describe Namespace do
end
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
before do
namespace.shared_runners_minutes_limit = 100
......@@ -431,24 +427,8 @@ describe Namespace do
namespace.parent = build(:group)
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
is_expected.to eq(false)
end
it 'returns false' do
is_expected.to eq(false)
end
end
......@@ -482,7 +462,6 @@ describe Namespace do
context 'when is subgroup', :nested_groups do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
namespace.parent = build(:group)
end
......@@ -499,28 +478,12 @@ describe Namespace do
describe '#shared_runners_enabled?' do
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!(: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
is_expected.to eq(true)
end
it "returns true" do
is_expected.to eq(true)
end
end
......
......@@ -620,24 +620,8 @@ describe Project do
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
is_expected.to eq(root_ancestor)
end
it 'returns root namespace' do
is_expected.to eq(root_ancestor)
end
end
......
......@@ -86,62 +86,35 @@ describe Ci::RegisterJobService do
end
end
context 'when group is subgroup' do
context 'when group is subgroup', :nested_groups do
let!(:root_ancestor) { create(:group) }
let!(:group) { create(:group, parent: root_ancestor) }
let!(:project) { create :project, shared_runners_enabled: true, group: group }
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
it "does return a build" do
expect(build).not_to be_nil
end
context 'when shared_runner_minutes_on_root_namespace is enabled', :nested_groups do
context 'when we are over limit on subnamespace' do
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
group.create_namespace_statistics(
shared_runners_seconds: 6001)
end
it "does return a build" do
it "limit is ignored and build is returned" do
expect(build).not_to be_nil
end
end
context 'when we are over limit on subnamespace' do
before do
group.create_namespace_statistics(
shared_runners_seconds: 6001)
end
it "limit is ignored and build is returned" do
expect(build).not_to be_nil
end
context 'when we are over limit on root namespace' do
before do
root_ancestor.create_namespace_statistics(
shared_runners_seconds: 6001)
end
context 'when we are over limit on root namespace' do
before do
root_ancestor.create_namespace_statistics(
shared_runners_seconds: 6001)
end
it "does not return a build" do
expect(build).to be_nil
end
it "does not return a build" do
expect(build).to be_nil
end
end
end
......
......@@ -43,37 +43,15 @@ describe UpdateBuildMinutesService do
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(:namespace) { create(:namespace, parent: root_ancestor) }
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) }
before do
stub_feature_flags(shared_runner_minutes_on_root_namespace: true)
end
it 'creates a statistics in root namespace' do
subject
it 'creates a statistics in root namespace' do
subject
expect(root_ancestor.namespace_statistics.reload.shared_runners_seconds)
.to eq(build.duration.to_i)
end
expect(root_ancestor.namespace_statistics.reload.shared_runners_seconds)
.to eq(build.duration.to_i)
end
end
end
......
......@@ -10,47 +10,24 @@ describe 'admin/groups/_form' do
allow(view).to receive(:visibility_level) { group.visibility_level }
end
describe 'when :shared_runner_minutes_on_root_namespace is disabled' 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) }
context 'when sub group is used', :nested_groups do
let(:root_ancestor) { create(:group) }
let(:group) { build(:group, parent: root_ancestor) }
it 'renders shared_runners_minutes_setting' do
render
it 'does not render shared_runners_minutes_setting' do
render
expect(rendered).to render_template('namespaces/_shared_runners_minutes_setting')
end
expect(rendered).not_to render_template('namespaces/_shared_runners_minutes_setting')
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(:group) { build(:group, parent: root_ancestor) }
it 'does not render shared_runners_minutes_setting' do
render
expect(rendered).not_to render_template('namespaces/_shared_runners_minutes_setting')
end
end
context 'when root group is used' do
let(:group) { build(:group) }
context 'when root group is used' do
let(:group) { build(:group) }
it 'does not render shared_runners_minutes_setting' do
render
it 'does not render shared_runners_minutes_setting' do
render
expect(rendered).to render_template('namespaces/_shared_runners_minutes_setting')
end
expect(rendered).to render_template('namespaces/_shared_runners_minutes_setting')
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