Commit 7eb5fc0b authored by Allison Browne's avatar Allison Browne

Respect namespaces with unlimited minutes

Internal Gitlab owned namespaces only (example: gitlab-org) have unlimited
minutes. Fix a bug where the builds were dropped when mintues were set
to 0 i.e. unlimited

Changelog: fixed
parent e690cc79
......@@ -274,6 +274,11 @@ class Namespace < ApplicationRecord
projects.with_shared_runners.any?
end
# Internal Gitlab owned namespaces only (example: gitlab-org)
def unlimited_minutes?
shared_runners_minutes_limit == 0
end
def user_ids_for_project_authorizations
[owner_id]
end
......
......@@ -77,6 +77,8 @@ module Ci
ServiceResponse.error(message: 'Feature not enabled')
elsif !build.running?
ServiceResponse.error(message: 'Build is not running')
elsif root_namespace.unlimited_minutes?
ServiceResponse.error(message: 'Namespace has unlimited minutes')
elsif !build.cost_factor_enabled?
ServiceResponse.error(message: 'Cost factor not enabled for build')
else
......
......@@ -80,6 +80,14 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
it_behaves_like 'returns early', 'Cost factor not enabled for build'
end
context 'when namespace has unlimited minutes' do
before do
namespace.update!(shared_runners_minutes_limit: 0)
end
it_behaves_like 'returns early', 'Namespace has unlimited minutes'
end
context 'when build has not been tracked recently' do
it 'considers the current consumption as zero' do
response = subject
......
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