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
6c35d95a
Commit
6c35d95a
authored
May 27, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move caught-up check for Ci::RegisterJobService to Core
parent
de52a3a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
47 deletions
+45
-47
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+17
-1
ee/app/services/ee/ci/register_job_service.rb
ee/app/services/ee/ci/register_job_service.rb
+0
-18
ee/spec/services/ci/register_job_service_spec.rb
ee/spec/services/ci/register_job_service_spec.rb
+0
-28
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+28
-0
No files found.
app/services/ci/register_job_service.rb
View file @
6c35d95a
...
...
@@ -22,11 +22,27 @@ module Ci
end
def
execute
(
params
=
{})
db_all_caught_up
=
::
Gitlab
::
Database
::
LoadBalancing
::
Sticking
.
all_caught_up?
(
:runner
,
runner
.
id
)
@metrics
.
increment_queue_operation
(
:queue_attempt
)
@metrics
.
observe_queue_time
(
:process
,
@runner
.
runner_type
)
do
result
=
@metrics
.
observe_queue_time
(
:process
,
@runner
.
runner_type
)
do
process_queue
(
params
)
end
# Since we execute this query against replica it might lead to false-positive
# We might receive the positive response: "hi, we don't have any more builds for you".
# This might not be true. If our DB replica is not up-to date with when runner event was generated
# we might still have some CI builds to be picked. Instead we should say to runner:
# "Hi, we don't have any more builds now, but not everything is right anyway, so try again".
# Runner will retry, but again, against replica, and again will check if replication lag did catch-up.
if
!
db_all_caught_up
&&
!
result
.
build
metrics
.
increment_queue_operation
(
:queue_replication_lag
)
::
Ci
::
RegisterJobService
::
Result
.
new
(
nil
,
false
)
# rubocop:disable Cop/AvoidReturnFromBlocks
else
result
end
end
private
...
...
ee/app/services/ee/ci/register_job_service.rb
View file @
6c35d95a
...
...
@@ -10,24 +10,6 @@ module EE
extend
ActiveSupport
::
Concern
extend
::
Gitlab
::
Utils
::
Override
def
execute
(
params
=
{})
db_all_caught_up
=
::
Gitlab
::
Database
::
LoadBalancing
::
Sticking
.
all_caught_up?
(
:runner
,
runner
.
id
)
super
.
tap
do
|
result
|
# Since we execute this query against replica it might lead to false-positive
# We might receive the positive response: "hi, we don't have any more builds for you".
# This might not be true. If our DB replica is not up-to date with when runner event was generated
# we might still have some CI builds to be picked. Instead we should say to runner:
# "Hi, we don't have any more builds now, but not everything is right anyway, so try again".
# Runner will retry, but again, against replica, and again will check if replication lag did catch-up.
if
!
db_all_caught_up
&&
!
result
.
build
metrics
.
increment_queue_operation
(
:queue_replication_lag
)
return
::
Ci
::
RegisterJobService
::
Result
.
new
(
nil
,
false
)
# rubocop:disable Cop/AvoidReturnFromBlocks
end
end
end
def
builds_for_shared_runner
# if disaster recovery is enabled, we disable quota
if
::
Feature
.
enabled?
(
:ci_queueing_disaster_recovery
,
runner
,
type: :ops
,
default_enabled: :yaml
)
...
...
ee/spec/services/ci/register_job_service_spec.rb
View file @
6c35d95a
...
...
@@ -10,34 +10,6 @@ RSpec.describe Ci::RegisterJobService do
let!
(
:pending_build
)
{
create
:ci_build
,
pipeline:
pipeline
}
describe
'#execute'
do
context
'checks database loadbalancing stickiness'
do
subject
{
described_class
.
new
(
shared_runner
).
execute
}
before
do
project
.
update!
(
shared_runners_enabled:
false
)
end
it
'result is valid if replica did caught-up'
do
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
)
.
and_return
(
true
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Sticking
).
to
receive
(
:all_caught_up?
)
.
with
(
:runner
,
shared_runner
.
id
)
{
true
}
expect
(
subject
).
to
be_valid
end
it
'result is invalid if replica did not caught-up'
do
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
)
.
and_return
(
true
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Sticking
).
to
receive
(
:all_caught_up?
)
.
with
(
:runner
,
shared_runner
.
id
)
{
false
}
expect
(
subject
).
not_to
be_valid
end
end
context
'shared runners minutes limit'
do
subject
{
described_class
.
new
(
shared_runner
).
execute
.
build
}
...
...
spec/services/ci/register_job_service_spec.rb
View file @
6c35d95a
...
...
@@ -14,6 +14,34 @@ module Ci
let!
(
:pending_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
describe
'#execute'
do
context
'checks database loadbalancing stickiness'
do
subject
{
described_class
.
new
(
shared_runner
).
execute
}
before
do
project
.
update!
(
shared_runners_enabled:
false
)
end
it
'result is valid if replica did caught-up'
do
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
)
.
and_return
(
true
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Sticking
).
to
receive
(
:all_caught_up?
)
.
with
(
:runner
,
shared_runner
.
id
)
{
true
}
expect
(
subject
).
to
be_valid
end
it
'result is invalid if replica did not caught-up'
do
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
)
.
and_return
(
true
)
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Sticking
).
to
receive
(
:all_caught_up?
)
.
with
(
:runner
,
shared_runner
.
id
)
{
false
}
expect
(
subject
).
not_to
be_valid
end
end
shared_examples
'handles runner assignment'
do
context
'runner follow tag list'
do
it
"picks build with the same tag"
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