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
47e6f1d6
Commit
47e6f1d6
authored
Jun 16, 2021
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor builds queue builder to avoid mutations
parent
e9368df2
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
92 deletions
+113
-92
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+12
-10
lib/gitlab/ci/queue/builder.rb
lib/gitlab/ci/queue/builder.rb
+101
-82
No files found.
app/services/ci/register_job_service.rb
View file @
47e6f1d6
...
...
@@ -105,28 +105,30 @@ module Ci
def
each_build
(
params
,
&
blk
)
queue
=
::
Gitlab
::
Ci
::
Queue
::
Builder
.
new
(
runner
)
if
runner
.
instance_type?
queue
.
builds_for_shared_runner
elsif
runner
.
group_type?
queue
.
builds_for_group_runner
else
queue
.
builds_for_project_runner
builds
=
begin
if
runner
.
instance_type?
queue
.
builds_for_shared_runner
elsif
runner
.
group_type?
queue
.
builds_for_group_runner
else
queue
.
builds_for_project_runner
end
end
# pick builds that does not have other tags than runner's one
queue
.
builds_matching_tag_ids
(
runner
.
tags
.
ids
)
builds
=
queue
.
builds_matching_tag_ids
(
builds
,
runner
.
tags
.
ids
)
# pick builds that have at least one tag
unless
runner
.
run_untagged?
queue
.
builds_with_any_tags
builds
=
queue
.
builds_with_any_tags
(
builds
)
end
# pick builds that older than specified age
if
params
.
key?
(
:job_age
)
queue
.
builds_queued_before
(
params
[
:job_age
].
seconds
.
ago
)
builds
=
queue
.
builds_queued_before
(
builds
,
params
[
:job_age
].
seconds
.
ago
)
end
build_ids
=
retrieve_queue
(
->
{
queue
.
build_ids
})
build_ids
=
retrieve_queue
(
->
{
queue
.
build_ids
(
builds
)
})
@metrics
.
observe_queue_size
(
->
{
build_ids
.
size
},
@runner
.
runner_type
)
...
...
lib/gitlab/ci/queue/builder.rb
View file @
47e6f1d6
This diff is collapsed.
Click to expand it.
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