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
d58b3767
Commit
d58b3767
authored
Mar 24, 2021
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor CTE part of big query to joins
parent
6916f5d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
4 deletions
+53
-4
ee/app/services/ee/ci/register_job_service.rb
ee/app/services/ee/ci/register_job_service.rb
+13
-2
ee/config/feature_flags/development/traversal_ids_for_quota_calculation.yml
...flags/development/traversal_ids_for_quota_calculation.yml
+8
-0
ee/spec/services/ci/register_job_service_spec.rb
ee/spec/services/ci/register_job_service_spec.rb
+32
-2
No files found.
ee/app/services/ee/ci/register_job_service.rb
View file @
d58b3767
...
...
@@ -74,8 +74,14 @@ module EE
# rubocop: disable CodeReuse/ActiveRecord
def
all_namespaces
namespaces
=
::
Namespace
.
reorder
(
nil
).
where
(
'namespaces.id = projects.namespace_id'
)
::
Gitlab
::
ObjectHierarchy
.
new
(
namespaces
,
options:
{
skip_ordering:
true
}).
roots
if
traversal_ids_enabled?
::
Namespace
.
where
(
'namespaces.id = project_namespaces.traversal_ids[1]'
)
.
joins
(
'INNER JOIN namespaces as project_namespaces ON project_namespaces.id = projects.namespace_id'
)
else
namespaces
=
::
Namespace
.
reorder
(
nil
).
where
(
'namespaces.id = projects.namespace_id'
)
::
Gitlab
::
ObjectHierarchy
.
new
(
namespaces
,
options:
{
skip_ordering:
true
}).
roots
end
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
@@ -87,6 +93,11 @@ module EE
ENV
[
'DISABLE_SHARED_RUNNER_BUILD_MINUTES_LIMIT'
].
to_s
!=
'true'
end
def
traversal_ids_enabled?
::
Feature
.
enabled?
(
:sync_traversal_ids
,
default_enabled: :yaml
)
&&
::
Feature
.
enabled?
(
:traversal_ids_for_quota_calculation
,
type: :development
,
default_enabled: :yaml
)
end
override
:pre_assign_runner_checks
def
pre_assign_runner_checks
super
.
merge
({
...
...
ee/config/feature_flags/development/traversal_ids_for_quota_calculation.yml
0 → 100644
View file @
d58b3767
---
name
:
traversal_ids_for_quota_calculation
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56760
rollout_issue_url
:
milestone
:
"
13.11"
type
:
development
group
:
group::continuous integration
default_enabled
:
false
ee/spec/services/ci/register_job_service_spec.rb
View file @
d58b3767
...
...
@@ -46,7 +46,22 @@ RSpec.describe Ci::RegisterJobService do
shared_runners_seconds:
runners_minutes_used
*
60
)
end
it
{
is_expected
.
to
be_kind_of
(
Ci
::
Build
)
}
context
'with flags enabled'
do
before
do
stub_feature_flags
(
sync_traversal_ids:
true
)
stub_feature_flags
(
traversal_ids_for_quota_calculation:
true
)
end
it
{
is_expected
.
to
be_kind_of
(
Ci
::
Build
)
}
end
context
'with flag disabled'
do
before
do
stub_feature_flags
(
traversal_ids_for_quota_calculation:
false
)
end
it
{
is_expected
.
to
be_kind_of
(
Ci
::
Build
)
}
end
end
shared_examples
'does not return a build'
do
|
runners_minutes_used
|
...
...
@@ -55,7 +70,22 @@ RSpec.describe Ci::RegisterJobService do
shared_runners_seconds:
runners_minutes_used
*
60
)
end
it
{
is_expected
.
to
be_nil
}
context
'with flags enabled'
do
before
do
stub_feature_flags
(
sync_traversal_ids:
true
)
stub_feature_flags
(
traversal_ids_for_quota_calculation:
true
)
end
it
{
is_expected
.
to
be_nil
}
end
context
'with flag disabled'
do
before
do
stub_feature_flags
(
traversal_ids_for_quota_calculation:
false
)
end
it
{
is_expected
.
to
be_nil
}
end
end
context
'when limit set at global level'
do
...
...
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