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
33651e72
Commit
33651e72
authored
Nov 03, 2017
by
Kamil Trzcinski
Committed by
ayufanpl
Nov 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Account shared runner minutes to top-level namespace
parent
497a2070
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
11 deletions
+56
-11
app/models/project.rb
app/models/project.rb
+4
-0
app/views/projects/jobs/_shared_runner_limit_warning.html.haml
...iews/projects/jobs/_shared_runner_limit_warning.html.haml
+3
-3
app/views/shared/_shared_runners_minutes_limit.html.haml
app/views/shared/_shared_runners_minutes_limit.html.haml
+1
-1
changelogs/unreleased-ee/account-shared-minutes-on-top-level-namespace.yml
...ased-ee/account-shared-minutes-on-top-level-namespace.yml
+5
-0
ee/app/controllers/groups/pipeline_quota_controller.rb
ee/app/controllers/groups/pipeline_quota_controller.rb
+11
-1
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+12
-3
ee/app/services/ee/ci/register_job_service.rb
ee/app/services/ee/ci/register_job_service.rb
+11
-2
ee/app/services/update_build_minutes_service.rb
ee/app/services/update_build_minutes_service.rb
+5
-1
lib/gitlab/group_hierarchy.rb
lib/gitlab/group_hierarchy.rb
+4
-0
No files found.
app/models/project.rb
View file @
33651e72
...
...
@@ -500,6 +500,10 @@ class Project < ActiveRecord::Base
.
base_and_ancestors
(
upto:
top
)
end
def
top_level_ancestor
@top_level_ancestor
||=
ancestors_upto
.
last
end
def
lfs_enabled?
return
namespace
.
lfs_enabled?
if
self
[
:lfs_enabled
].
nil?
...
...
app/views/projects/jobs/_shared_runner_limit_warning.html.haml
View file @
33651e72
-
if
project
.
namespace
.
shared_runners_minutes_used?
-
quota_used
=
project
.
namespace
.
shared_runners_minutes
-
quota_limit
=
project
.
namespace
.
actual_shared_runners_minutes_limit
-
if
project
.
shared_runners_limit_
namespace
.
shared_runners_minutes_used?
-
quota_used
=
project
.
shared_runners_limit_
namespace
.
shared_runners_minutes
-
quota_limit
=
project
.
shared_runners_limit_
namespace
.
actual_shared_runners_minutes_limit
.bs-callout.bs-callout-warning
%p
You have used all your shared Runners pipeline minutes.
...
...
app/views/shared/_shared_runners_minutes_limit.html.haml
View file @
33651e72
-
project
=
local_assigns
.
fetch
(
:project
,
nil
)
-
namespace
=
local_assigns
.
fetch
(
:namespace
,
project
&&
project
.
namespace
)
-
namespace
=
local_assigns
.
fetch
(
:namespace
,
project
&&
project
.
shared_runners_limit_
namespace
)
-
scope
=
(
project
||
namespace
).
full_path
-
has_limit
=
(
project
||
namespace
).
shared_runners_minutes_limit_enabled?
-
can_see_status
=
project
.
nil?
||
can?
(
current_user
,
:create_pipeline
,
project
)
...
...
changelogs/unreleased-ee/account-shared-minutes-on-top-level-namespace.yml
0 → 100644
View file @
33651e72
---
title
:
Account shared runner minutes to top-level namespace
merge_request
:
author
:
type
:
fixed
ee/app/controllers/groups/pipeline_quota_controller.rb
View file @
33651e72
...
...
@@ -4,6 +4,16 @@ class Groups::PipelineQuotaController < Groups::ApplicationController
layout
'group_settings'
def
index
@projects
=
@group
.
projects
.
with_shared_runners_limit_enabled
.
page
(
params
[
:page
])
@projects
=
all_projects
.
with_shared_runners_limit_enabled
.
page
(
params
[
:page
])
end
private
def
all_projects
if
Feature
.
enabled?
(
:account_on_namespace
)
@group
.
all_projects
else
@group
.
projects
end
end
end
ee/app/models/ee/project.rb
View file @
33651e72
...
...
@@ -54,7 +54,7 @@ module EE
to: :statistics
,
allow_nil:
true
delegate
:actual_shared_runners_minutes_limit
,
:shared_runners_minutes_used?
,
to: :namespace
:shared_runners_minutes_used?
,
to: :
shared_runners_limit_
namespace
validates
:repository_size_limit
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
,
allow_nil:
true
}
...
...
@@ -82,6 +82,14 @@ module EE
end
end
def
shared_runners_limit_namespace
if
Feature
.
enabled?
(
:account_on_namespace
)
top_level_ancestor
else
namespace
end
end
def
mirror
super
&&
feature_available?
(
:repository_mirrors
)
end
...
...
@@ -190,11 +198,12 @@ module EE
end
def
shared_runners_available?
super
&&
!
namespace
.
shared_runners_minutes_used?
super
&&
!
shared_runners_limit_
namespace
.
shared_runners_minutes_used?
end
def
shared_runners_minutes_limit_enabled?
!
public
?
&&
shared_runners_enabled?
&&
namespace
.
shared_runners_minutes_limit_enabled?
!
public
?
&&
shared_runners_enabled?
&&
shared_runners_limit_namespace
.
shared_runners_minutes_limit_enabled?
end
def
feature_available?
(
feature
,
user
=
nil
)
...
...
ee/app/services/ee/ci/register_job_service.rb
View file @
33651e72
...
...
@@ -17,8 +17,7 @@ module EE
end
def
builds_check_limit
::
Namespace
.
reorder
(
nil
)
.
where
(
'namespaces.id = projects.namespace_id'
)
all_namespaces
.
joins
(
'LEFT JOIN namespace_statistics ON namespace_statistics.namespace_id = namespaces.id'
)
.
where
(
'COALESCE(namespaces.shared_runners_minutes_limit, ?, 0) = 0 OR '
\
'COALESCE(namespace_statistics.shared_runners_seconds, 0) < COALESCE(namespaces.shared_runners_minutes_limit, ?, 0) * 60'
,
...
...
@@ -26,6 +25,16 @@ module EE
.
select
(
'1'
)
end
def
all_namespaces
if
Feature
.
enabled?
(
:account_on_namespace
)
::
Gitlab
::
GroupHierarchy
.
new
(
::
Namespace
.
where
(
'namespaces.id = projects.namespace_id'
))
.
roots
else
::
Namespace
.
reorder
(
nil
)
.
where
(
'namespaces.id = projects.namespace_id'
)
end
end
def
application_shared_runners_minutes
current_application_settings
.
shared_runners_minutes
end
...
...
ee/app/services/update_build_minutes_service.rb
View file @
33651e72
...
...
@@ -22,6 +22,10 @@ class UpdateBuildMinutesService < BaseService
end
def
namespace
if
Feature
.
enabled
(
:account_on_top_level
)
project
.
namespace
.
top_level_parent
else
project
.
namespace
end
end
end
lib/gitlab/group_hierarchy.rb
View file @
33651e72
...
...
@@ -33,6 +33,10 @@ module Gitlab
base_and_ancestors
(
upto:
upto
).
where
.
not
(
id:
ancestors_base
.
select
(
:id
))
end
def
roots
base_and_ancestors
.
where
(
namespaces:
{
parent_id:
nil
})
end
# Returns a relation that includes the ancestors_base set of groups
# and all their ancestors (recursively).
#
...
...
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