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
end
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?
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
def stick_build_if_status_changed
......
......@@ -90,8 +90,7 @@ module EE
has_many :sourced_pipelines, class_name: 'Ci::Sources::Project', foreign_key: :source_project_id
scope :with_shared_runners_limit_enabled, -> do
if ::Feature.enabled?(:ci_minutes_enforce_quota_for_public_projects, default_enabled: true) &&
::Ci::Runner.has_shared_runners_with_non_zero_public_cost?
if ::Ci::Runner.has_shared_runners_with_non_zero_public_cost?
with_shared_runners
else
with_shared_runners.non_public_only
......@@ -282,17 +281,7 @@ module EE
end
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?
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?
shared_runners_enabled? && shared_runners_limit_namespace.shared_runners_minutes_limit_enabled?
end
# This makes the feature disabled by default, in contrary to how
......
......@@ -28,11 +28,7 @@ module EE
def builds_for_shared_runner
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)
else
legacy_enforce_minutes_for_non_public_projects(super)
end
end
# rubocop: disable CodeReuse/ActiveRecord
......@@ -46,15 +42,6 @@ module EE
end
# 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
def builds_check_limit
all_namespaces
......
......@@ -6,11 +6,7 @@ class UpdateBuildMinutesService < BaseService
return unless build.complete?
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)
else
legacy_count_non_public_projects(build)
end
end
private
......@@ -28,16 +24,6 @@ class UpdateBuildMinutesService < BaseService
shared_runners_seconds: duration_with_cost_factor)
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
namespace.namespace_statistics || namespace.create_namespace_statistics
end
......
......@@ -80,14 +80,6 @@ describe Ci::Build do
end
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
context 'updates pipeline minutes' do
......
......@@ -223,22 +223,6 @@ describe Project do
expect(described_class.with_shared_runners_limit_enabled).to include(private_project_with_shared_runners)
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
describe '.has_vulnerabilities' do
......@@ -1024,14 +1008,6 @@ describe Project do
end
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
context 'for internal project' do
......
......@@ -86,14 +86,6 @@ describe Ci::RegisterJobService do
end
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
......
......@@ -71,18 +71,6 @@ describe UpdateBuildMinutesService do
.to eq((build.duration.to_i * 1.234).to_i)
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
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