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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
637894de
Commit
637894de
authored
Jan 25, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-ci-requests-concurrency' into 'master'
Fix CI requests concurrency See merge request !8760
parents
6cfe60df
31be74c7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
12 deletions
+38
-12
app/services/ci/register_build_service.rb
app/services/ci/register_build_service.rb
+4
-2
changelogs/unreleased/fix-ci-requests-concurrency-for-newer-runners.yml
...eleased/fix-ci-requests-concurrency-for-newer-runners.yml
+3
-0
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+16
-9
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+14
-0
spec/services/ci/register_build_service_spec.rb
spec/services/ci/register_build_service_spec.rb
+1
-1
No files found.
app/services/ci/register_build_service.rb
View file @
637894de
...
@@ -6,6 +6,8 @@ module Ci
...
@@ -6,6 +6,8 @@ module Ci
attr_reader
:runner
attr_reader
:runner
Result
=
Struct
.
new
(
:build
,
:valid?
)
def
initialize
(
runner
)
def
initialize
(
runner
)
@runner
=
runner
@runner
=
runner
end
end
...
@@ -29,10 +31,10 @@ module Ci
...
@@ -29,10 +31,10 @@ module Ci
build
.
run!
build
.
run!
end
end
build
Result
.
new
(
build
,
true
)
rescue
StateMachines
::
InvalidTransition
,
ActiveRecord
::
StaleObjectError
rescue
StateMachines
::
InvalidTransition
,
ActiveRecord
::
StaleObjectError
nil
Result
.
new
(
build
,
false
)
end
end
private
private
...
...
changelogs/unreleased/fix-ci-requests-concurrency-for-newer-runners.yml
0 → 100644
View file @
637894de
---
title
:
'
Fix
CI
requests
concurrency
for
newer
runners
that
prevents
from
picking
pending
builds
(from
1.9.0-rc5)'
merge_request
:
8760
lib/ci/api/builds.rb
View file @
637894de
...
@@ -18,24 +18,31 @@ module Ci
...
@@ -18,24 +18,31 @@ module Ci
if
current_runner
.
is_runner_queue_value_latest?
(
params
[
:last_update
])
if
current_runner
.
is_runner_queue_value_latest?
(
params
[
:last_update
])
header
'X-GitLab-Last-Update'
,
params
[
:last_update
]
header
'X-GitLab-Last-Update'
,
params
[
:last_update
]
Gitlab
::
Metrics
.
add_event
(
:build_not_found_cached
)
return
build_not_found!
return
build_not_found!
end
end
new_update
=
current_runner
.
ensure_runner_queue_value
new_update
=
current_runner
.
ensure_runner_queue_value
build
=
Ci
::
RegisterBuildService
.
new
(
current_runner
).
execute
result
=
Ci
::
RegisterBuildService
.
new
(
current_runner
).
execute
if
build
if
result
.
valid?
Gitlab
::
Metrics
.
add_event
(
:build_found
,
if
result
.
build
project:
build
.
project
.
path_with_namespace
)
Gitlab
::
Metrics
.
add_event
(
:build_found
,
project:
result
.
build
.
project
.
path_with_namespace
)
present
build
,
with:
Entities
::
BuildDetails
present
result
.
build
,
with:
Entities
::
BuildDetails
else
else
Gitlab
::
Metrics
.
add_event
(
:build_not_found
)
Gitlab
::
Metrics
.
add_event
(
:build_not_found
)
header
'X-GitLab-Last-Update'
,
new_update
header
'X-GitLab-Last-Update'
,
new_update
build_not_found!
build_not_found!
end
else
# We received build that is invalid due to concurrency conflict
Gitlab
::
Metrics
.
add_event
(
:build_invalid
)
conflict!
end
end
end
end
...
...
spec/requests/ci/api/builds_spec.rb
View file @
637894de
...
@@ -91,6 +91,20 @@ describe Ci::API::Builds do
...
@@ -91,6 +91,20 @@ describe Ci::API::Builds do
expect
{
register_builds
}.
to
change
{
runner
.
reload
.
contacted_at
}
expect
{
register_builds
}.
to
change
{
runner
.
reload
.
contacted_at
}
end
end
context
'when concurrently updating build'
do
before
do
expect_any_instance_of
(
Ci
::
Build
).
to
receive
(
:run!
).
and_raise
(
ActiveRecord
::
StaleObjectError
.
new
(
nil
,
nil
))
end
it
'returns a conflict'
do
register_builds
info:
{
platform: :darwin
}
expect
(
response
).
to
have_http_status
(
409
)
expect
(
response
.
headers
).
not_to
have_key
(
'X-GitLab-Last-Update'
)
end
end
context
'registry credentials'
do
context
'registry credentials'
do
let
(
:registry_credentials
)
do
let
(
:registry_credentials
)
do
{
'type'
=>
'registry'
,
{
'type'
=>
'registry'
,
...
...
spec/services/ci/register_build_service_spec.rb
View file @
637894de
...
@@ -171,7 +171,7 @@ module Ci
...
@@ -171,7 +171,7 @@ module Ci
end
end
def
execute
(
runner
)
def
execute
(
runner
)
described_class
.
new
(
runner
).
execute
described_class
.
new
(
runner
).
execute
.
build
end
end
end
end
end
end
...
...
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