Commit 2e5d6a19 authored by Aleksei Lipniagov's avatar Aleksei Lipniagov

Remove CI Minutes FFs from the codebase

Drop :ci_minutes_enforce_quota_for_public_projects and
:ci_minutes_track_for_public_projects from the codebase.
parent 461d574c
...@@ -37,15 +37,7 @@ module EE ...@@ -37,15 +37,7 @@ module EE
end end
def shared_runners_minutes_limit_enabled? def shared_runners_minutes_limit_enabled?
if ::Feature.enabled?(:ci_minutes_track_for_public_projects, project.shared_runners_limit_namespace, default_enabled: true)
project.shared_runners_minutes_limit_enabled? && runner&.minutes_cost_factor(project.visibility_level)&.positive? project.shared_runners_minutes_limit_enabled? && runner&.minutes_cost_factor(project.visibility_level)&.positive?
else
legacy_shared_runners_minutes_limit_enabled?
end
end
def legacy_shared_runners_minutes_limit_enabled?
runner && runner.instance_type? && project.shared_runners_minutes_limit_enabled?
end end
def stick_build_if_status_changed def stick_build_if_status_changed
......
...@@ -90,8 +90,7 @@ module EE ...@@ -90,8 +90,7 @@ module EE
has_many :sourced_pipelines, class_name: 'Ci::Sources::Project', foreign_key: :source_project_id has_many :sourced_pipelines, class_name: 'Ci::Sources::Project', foreign_key: :source_project_id
scope :with_shared_runners_limit_enabled, -> do scope :with_shared_runners_limit_enabled, -> do
if ::Feature.enabled?(:ci_minutes_enforce_quota_for_public_projects, default_enabled: true) && if ::Ci::Runner.has_shared_runners_with_non_zero_public_cost?
::Ci::Runner.has_shared_runners_with_non_zero_public_cost?
with_shared_runners with_shared_runners
else else
with_shared_runners.non_public_only with_shared_runners.non_public_only
...@@ -282,17 +281,7 @@ module EE ...@@ -282,17 +281,7 @@ module EE
end end
def shared_runners_minutes_limit_enabled? def shared_runners_minutes_limit_enabled?
if ::Feature.enabled?(:ci_minutes_track_for_public_projects, shared_runners_limit_namespace, default_enabled: true) shared_runners_enabled? && shared_runners_limit_namespace.shared_runners_minutes_limit_enabled?
shared_runners_enabled? &&
shared_runners_limit_namespace.shared_runners_minutes_limit_enabled?
else
legacy_shared_runners_minutes_limit_enabled?
end
end
def legacy_shared_runners_minutes_limit_enabled?
!public? && shared_runners_enabled? &&
shared_runners_limit_namespace.shared_runners_minutes_limit_enabled?
end end
# This makes the feature disabled by default, in contrary to how # This makes the feature disabled by default, in contrary to how
......
...@@ -28,11 +28,7 @@ module EE ...@@ -28,11 +28,7 @@ module EE
def builds_for_shared_runner def builds_for_shared_runner
return super unless shared_runner_build_limits_feature_enabled? return super unless shared_runner_build_limits_feature_enabled?
if ::Feature.enabled?(:ci_minutes_enforce_quota_for_public_projects, default_enabled: true)
enforce_minutes_based_on_cost_factors(super) enforce_minutes_based_on_cost_factors(super)
else
legacy_enforce_minutes_for_non_public_projects(super)
end
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
...@@ -46,15 +42,6 @@ module EE ...@@ -46,15 +42,6 @@ module EE
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def legacy_enforce_minutes_for_non_public_projects(relation)
# select projects which have allowed number of shared runner minutes or are public
relation
.where("projects.visibility_level=? OR (#{builds_check_limit.to_sql})=1", # rubocop:disable GitlabSecurity/SqlInjection
::Gitlab::VisibilityLevel::PUBLIC)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def builds_check_limit def builds_check_limit
all_namespaces all_namespaces
......
...@@ -6,11 +6,7 @@ class UpdateBuildMinutesService < BaseService ...@@ -6,11 +6,7 @@ class UpdateBuildMinutesService < BaseService
return unless build.complete? return unless build.complete?
return unless build.duration&.positive? return unless build.duration&.positive?
if ::Feature.enabled?(:ci_minutes_track_for_public_projects, namespace, default_enabled: true)
count_projects_based_on_cost_factors(build) count_projects_based_on_cost_factors(build)
else
legacy_count_non_public_projects(build)
end
end end
private private
...@@ -28,16 +24,6 @@ class UpdateBuildMinutesService < BaseService ...@@ -28,16 +24,6 @@ class UpdateBuildMinutesService < BaseService
shared_runners_seconds: duration_with_cost_factor) shared_runners_seconds: duration_with_cost_factor)
end end
def legacy_count_non_public_projects(build)
return if project.public?
ProjectStatistics.update_counters(project_statistics,
shared_runners_seconds: build.duration)
NamespaceStatistics.update_counters(namespace_statistics,
shared_runners_seconds: build.duration)
end
def namespace_statistics def namespace_statistics
namespace.namespace_statistics || namespace.create_namespace_statistics namespace.namespace_statistics || namespace.create_namespace_statistics
end end
......
...@@ -80,14 +80,6 @@ describe Ci::Build do ...@@ -80,14 +80,6 @@ describe Ci::Build do
end end
it_behaves_like 'depends on runner presence and type' it_behaves_like 'depends on runner presence and type'
context 'and :ci_minutes_track_for_public_projects FF is disabled' do
before do
stub_feature_flags(ci_minutes_track_for_public_projects: false)
end
it_behaves_like 'depends on runner presence and type'
end
end end
context 'updates pipeline minutes' do context 'updates pipeline minutes' do
......
...@@ -223,22 +223,6 @@ describe Project do ...@@ -223,22 +223,6 @@ describe Project do
expect(described_class.with_shared_runners_limit_enabled).to include(private_project_with_shared_runners) expect(described_class.with_shared_runners_limit_enabled).to include(private_project_with_shared_runners)
end end
end end
context 'and :ci_minutes_enforce_quota_for_public_projects FF is disabled' do
before do
stub_feature_flags(ci_minutes_enforce_quota_for_public_projects: false)
end
it 'does not return public projects' do
public_project_with_shared_runners = create(:project, :public, shared_runners_enabled: true)
internal_project_with_shared_runners = create(:project, :internal, shared_runners_enabled: true)
private_project_with_shared_runners = create(:project, :private, shared_runners_enabled: true)
expect(described_class.with_shared_runners_limit_enabled).not_to include(public_project_with_shared_runners)
expect(described_class.with_shared_runners_limit_enabled).to include(internal_project_with_shared_runners)
expect(described_class.with_shared_runners_limit_enabled).to include(private_project_with_shared_runners)
end
end
end end
describe '.has_vulnerabilities' do describe '.has_vulnerabilities' do
...@@ -1024,14 +1008,6 @@ describe Project do ...@@ -1024,14 +1008,6 @@ describe Project do
end end
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
context 'and :ci_minutes_track_for_public_projects FF is disabled' do
before do
stub_feature_flags(ci_minutes_track_for_public_projects: false)
end
it { is_expected.to be_falsey }
end
end end
context 'for internal project' do context 'for internal project' do
......
...@@ -86,14 +86,6 @@ describe Ci::RegisterJobService do ...@@ -86,14 +86,6 @@ describe Ci::RegisterJobService do
end end
it_behaves_like 'does not return a build', 11 it_behaves_like 'does not return a build', 11
context 'and :ci_minutes_enforce_quota_for_public_projects FF is disabled' do
before do
stub_feature_flags(ci_minutes_enforce_quota_for_public_projects: false)
end
it_behaves_like 'returns a build', 11
end
end end
end end
end end
......
...@@ -71,18 +71,6 @@ describe UpdateBuildMinutesService do ...@@ -71,18 +71,6 @@ describe UpdateBuildMinutesService do
.to eq((build.duration.to_i * 1.234).to_i) .to eq((build.duration.to_i * 1.234).to_i)
end end
end end
context 'when :ci_minutes_track_for_public_projects FF is disabled' do
before do
stub_feature_flags(ci_minutes_track_for_public_projects: false)
end
it "does not create/update statistics" do
subject
expect(namespace.namespace_statistics).to be_nil
end
end
end end
context 'for specific runner' do context 'for specific runner' 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