Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9148fd24
Commit
9148fd24
authored
Dec 22, 2020
by
Etienne Baqué
Committed by
Paul Slaughter
Dec 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove quota data for subgroups
Made namespace_eligible? publicly visible. Added rspec accordingly.
parent
219df0a7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
31 deletions
+120
-31
ee/app/models/ci/minutes/quota.rb
ee/app/models/ci/minutes/quota.rb
+19
-8
ee/app/views/namespaces/_shared_runner_status.html.haml
ee/app/views/namespaces/_shared_runner_status.html.haml
+2
-2
ee/changelogs/unreleased/292445-no-quota-for-subgroup.yml
ee/changelogs/unreleased/292445-no-quota-for-subgroup.yml
+5
-0
ee/spec/features/profiles/usage_quotas_spec.rb
ee/spec/features/profiles/usage_quotas_spec.rb
+1
-1
ee/spec/helpers/ee/namespaces_helper_spec.rb
ee/spec/helpers/ee/namespaces_helper_spec.rb
+22
-6
ee/spec/models/ci/minutes/quota_spec.rb
ee/spec/models/ci/minutes/quota_spec.rb
+65
-14
locale/gitlab.pot
locale/gitlab.pot
+6
-0
No files found.
ee/app/models/ci/minutes/quota.rb
View file @
9148fd24
...
@@ -19,12 +19,7 @@ module Ci
...
@@ -19,12 +19,7 @@ module Ci
# Status of the monthly allowance being used.
# Status of the monthly allowance being used.
def
monthly_minutes_report
def
monthly_minutes_report
if
enabled?
Report
.
new
(
monthly_minutes_used
,
minutes_limit
,
report_status
)
status
=
monthly_minutes_used_up?
?
:over_quota
:
:under_quota
Report
.
new
(
monthly_minutes_used
,
monthly_minutes
,
status
)
else
Report
.
new
(
monthly_minutes_used
,
'Unlimited'
,
:disabled
)
end
end
end
def
monthly_percent_used
def
monthly_percent_used
...
@@ -65,12 +60,28 @@ module Ci
...
@@ -65,12 +60,28 @@ module Ci
100
*
total_minutes_remaining
.
to_i
/
total_minutes
100
*
total_minutes_remaining
.
to_i
/
total_minutes
end
end
private
def
namespace_eligible?
def
namespace_eligible?
namespace
.
root?
&&
namespace
.
any_project_with_shared_runners_enabled?
namespace
.
root?
&&
namespace
.
any_project_with_shared_runners_enabled?
end
end
private
def
minutes_limit
return
monthly_minutes
if
enabled?
if
namespace_eligible?
_
(
'Unlimited'
)
else
_
(
'Not supported'
)
end
end
def
report_status
return
:disabled
unless
enabled?
monthly_minutes_used_up?
?
:over_quota
:
:under_quota
end
def
total_minutes_remaining
def
total_minutes_remaining
[
total_minutes
.
to_i
-
total_minutes_used
,
0
].
max
[
total_minutes
.
to_i
-
total_minutes_used
,
0
].
max
end
end
...
...
ee/app/views/namespaces/_shared_runner_status.html.haml
View file @
9148fd24
-
namespace
=
local_assigns
.
fetch
(
:namespace
)
-
namespace
=
local_assigns
.
fetch
(
:namespace
)
-
minutes_quota
=
namespace
.
ci_minutes_quota
-
minutes_quota
=
namespace
.
ci_minutes_quota
-
if
namespace
.
any_project_with_shared_runners_enabled
?
-
if
minutes_quota
.
namespace_eligible
?
%li
%li
%span
.light
Pipeline minutes quota:
%span
.light
=
_
(
'Pipeline minutes quota:'
)
%strong
%strong
=
ci_minutes_report
(
minutes_quota
.
monthly_minutes_report
)
=
ci_minutes_report
(
minutes_quota
.
monthly_minutes_report
)
=
link_to
sprite_icon
(
'question-o'
),
help_page_path
(
'user/admin_area/settings/continuous_integration'
,
anchor:
'shared-runners-pipeline-minutes-quota'
),
target:
'_blank'
=
link_to
sprite_icon
(
'question-o'
),
help_page_path
(
'user/admin_area/settings/continuous_integration'
,
anchor:
'shared-runners-pipeline-minutes-quota'
),
target:
'_blank'
ee/changelogs/unreleased/292445-no-quota-for-subgroup.yml
0 → 100644
View file @
9148fd24
---
title
:
Remove quota data for subgroups
merge_request
:
50163
author
:
type
:
fixed
ee/spec/features/profiles/usage_quotas_spec.rb
View file @
9148fd24
...
@@ -25,7 +25,7 @@ RSpec.describe 'Profile > Usage Quota' do
...
@@ -25,7 +25,7 @@ RSpec.describe 'Profile > Usage Quota' do
describe
'shared runners use'
do
describe
'shared runners use'
do
where
(
:shared_runners_enabled
,
:used
,
:quota
,
:usage_class
,
:usage_text
)
do
where
(
:shared_runners_enabled
,
:used
,
:quota
,
:usage_class
,
:usage_text
)
do
false
|
300
|
500
|
'success'
|
'300 /
Unlimi
ted minutes 0% used'
false
|
300
|
500
|
'success'
|
'300 /
Not suppor
ted minutes 0% used'
true
|
300
|
nil
|
'success'
|
'300 / Unlimited minutes Unlimited'
true
|
300
|
nil
|
'success'
|
'300 / Unlimited minutes Unlimited'
true
|
300
|
500
|
'success'
|
'300 / 500 minutes 60% used'
true
|
300
|
500
|
'success'
|
'300 / 500 minutes 60% used'
true
|
1000
|
500
|
'danger'
|
'1000 / 500 minutes 200% used'
true
|
1000
|
500
|
'danger'
|
'1000 / 500 minutes 200% used'
...
...
ee/spec/helpers/ee/namespaces_helper_spec.rb
View file @
9148fd24
...
@@ -55,19 +55,35 @@ RSpec.describe EE::NamespacesHelper do
...
@@ -55,19 +55,35 @@ RSpec.describe EE::NamespacesHelper do
describe
'rendering monthly minutes report'
do
describe
'rendering monthly minutes report'
do
let
(
:report
)
{
quota
.
monthly_minutes_report
}
let
(
:report
)
{
quota
.
monthly_minutes_report
}
context
"when
it's unlimit
ed"
do
context
"when
ci minutes quota is not enabl
ed"
do
before
do
before
do
allow
(
user_group
).
to
receive
(
:shared_runners_minutes_limit_enabled?
).
and_return
(
false
)
allow
(
user_group
).
to
receive
(
:shared_runners_minutes_limit_enabled?
).
and_return
(
false
)
end
end
it
'returns Unlimited for the limit section'
do
context
'and the namespace is eligible for unlimited'
do
expect
(
helper
.
ci_minutes_report
(
report
)).
to
match
(
%r{0 / Unlimited}
)
before
do
allow
(
quota
).
to
receive
(
:namespace_eligible?
).
and_return
(
true
)
end
it
'returns Unlimited for the limit section'
do
expect
(
helper
.
ci_minutes_report
(
report
)).
to
match
(
%r{0 / Unlimited}
)
end
it
'returns the proper value for the used section'
do
allow
(
user_group
).
to
receive
(
:shared_runners_seconds
).
and_return
(
100
*
60
)
expect
(
helper
.
ci_minutes_report
(
report
)).
to
match
(
%r{100 / Unlimited}
)
end
end
end
it
'returns the proper value for the used section'
do
context
'and the namespace is not eligible for unlimited'
do
allow
(
user_group
).
to
receive
(
:shared_runners_seconds
).
and_return
(
100
*
60
)
before
do
allow
(
quota
).
to
receive
(
:namespace_eligible?
).
and_return
(
false
)
end
expect
(
helper
.
ci_minutes_report
(
report
)).
to
match
(
%r{100 / Unlimited}
)
it
'returns Not supported for the limit section'
do
expect
(
helper
.
ci_minutes_report
(
report
)).
to
match
(
%r{0 / Not supported}
)
end
end
end
end
end
...
...
ee/spec/models/ci/minutes/quota_spec.rb
View file @
9148fd24
...
@@ -4,14 +4,14 @@ require 'spec_helper'
...
@@ -4,14 +4,14 @@ require 'spec_helper'
RSpec
.
describe
Ci
::
Minutes
::
Quota
do
RSpec
.
describe
Ci
::
Minutes
::
Quota
do
using
RSpec
::
Parameterized
::
TableSyntax
using
RSpec
::
Parameterized
::
TableSyntax
let_it_be
(
:namespace
)
do
let_it_be
_with_reload
(
:namespace
)
do
create
(
:namespace
,
namespace_statistics:
create
(
:namespace_statistics
))
create
(
:namespace
,
namespace_statistics:
create
(
:namespace_statistics
))
end
end
let
(
:quota
)
{
described_class
.
new
(
namespace
)
}
let
(
:quota
)
{
described_class
.
new
(
namespace
)
}
describe
'#enabled?'
do
describe
'#enabled?'
do
let
_it_be
(
:project
)
{
create
(
:project
,
namespace:
namespace
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
namespace
)
}
subject
{
quota
.
enabled?
}
subject
{
quota
.
enabled?
}
...
@@ -64,32 +64,49 @@ RSpec.describe Ci::Minutes::Quota do
...
@@ -64,32 +64,49 @@ RSpec.describe Ci::Minutes::Quota do
end
end
describe
'#monthly_minutes_report'
do
describe
'#monthly_minutes_report'
do
context
'when
unlimit
ed'
do
context
'when
the quota is not enabl
ed'
do
before
do
before
do
allow
(
quota
).
to
receive
(
:enabled?
).
and_return
(
false
)
allow
(
quota
).
to
receive
(
:enabled?
).
and_return
(
false
)
allow
(
quota
).
to
receive
(
:namespace_eligible?
).
and_return
(
namespace_eligible
)
end
end
context
'when minutes are not used'
do
context
'when the namespace is not eligible'
do
it
'returns unlimited report with no usage'
do
let
(
:namespace_eligible
)
{
false
}
it
'returns not supported report with no usage'
do
report
=
quota
.
monthly_minutes_report
report
=
quota
.
monthly_minutes_report
expect
(
report
.
limit
).
to
eq
'
Unlimi
ted'
expect
(
report
.
limit
).
to
eq
'
Not suppor
ted'
expect
(
report
.
used
).
to
eq
0
expect
(
report
.
used
).
to
eq
0
expect
(
report
.
status
).
to
eq
:disabled
expect
(
report
.
status
).
to
eq
:disabled
end
end
end
end
context
'when minutes are used'
do
context
'when the namespace is eligible'
do
before
do
let
(
:namespace_eligible
)
{
true
}
namespace
.
namespace_statistics
.
shared_runners_seconds
=
20
.
minutes
context
'when minutes are not used'
do
it
'returns unlimited report with no usage'
do
report
=
quota
.
monthly_minutes_report
expect
(
report
.
limit
).
to
eq
'Unlimited'
expect
(
report
.
used
).
to
eq
0
expect
(
report
.
status
).
to
eq
:disabled
end
end
end
it
'returns unlimited report with usage'
do
context
'when minutes are used'
do
report
=
quota
.
monthly_minutes_report
before
do
namespace
.
namespace_statistics
.
shared_runners_seconds
=
20
.
minutes
end
expect
(
report
.
limit
).
to
eq
'Unlimited'
it
'returns unlimited report with usage'
do
expect
(
report
.
used
).
to
eq
20
report
=
quota
.
monthly_minutes_report
expect
(
report
.
status
).
to
eq
:disabled
expect
(
report
.
limit
).
to
eq
'Unlimited'
expect
(
report
.
used
).
to
eq
20
expect
(
report
.
status
).
to
eq
:disabled
end
end
end
end
end
end
end
...
@@ -373,4 +390,38 @@ RSpec.describe Ci::Minutes::Quota do
...
@@ -373,4 +390,38 @@ RSpec.describe Ci::Minutes::Quota do
it
{
is_expected
.
to
eq
(
result
)
}
it
{
is_expected
.
to
eq
(
result
)
}
end
end
end
end
describe
'#namespace_eligible?'
do
subject
{
quota
.
namespace_eligible?
}
context
'when namespace is a subgroup'
do
it
'is false'
do
allow
(
namespace
).
to
receive
(
:root?
).
and_return
(
false
)
expect
(
subject
).
to
be_falsey
end
end
context
'when namespace is root'
do
before
do
create
(
:project
,
namespace:
namespace
,
shared_runners_enabled:
shared_runners_enabled
)
end
context
'and it has a project without any shared runner enabled'
do
let
(
:shared_runners_enabled
)
{
false
}
it
'is false'
do
expect
(
subject
).
to
be_falsey
end
end
context
'and it has a project with shared runner enabled'
do
let
(
:shared_runners_enabled
)
{
true
}
it
'is true'
do
expect
(
subject
).
to
be_truthy
end
end
end
end
end
end
locale/gitlab.pot
View file @
9148fd24
...
@@ -19118,6 +19118,9 @@ msgstr ""
...
@@ -19118,6 +19118,9 @@ msgstr ""
msgid "Not started"
msgid "Not started"
msgstr ""
msgstr ""
msgid "Not supported"
msgstr ""
msgid "Note"
msgid "Note"
msgstr ""
msgstr ""
...
@@ -20317,6 +20320,9 @@ msgstr ""
...
@@ -20317,6 +20320,9 @@ msgstr ""
msgid "Pipeline minutes quota"
msgid "Pipeline minutes quota"
msgstr ""
msgstr ""
msgid "Pipeline minutes quota:"
msgstr ""
msgid "Pipeline ran in fork of project"
msgid "Pipeline ran in fork of project"
msgstr ""
msgstr ""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment