BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
67b407b4
Commit
67b407b4
authored
Jan 25, 2017
by
Grzegorz Bizon
Committed by
DJ Mountney
Jan 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'fix-ci-requests-concurrency' into 'master'
Fix CI requests concurrency See merge request !8760
parent
db8c1d32
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
7 deletions
+33
-7
register_build_service.rb
app/services/ci/register_build_service.rb
+4
-2
fix-ci-requests-concurrency-for-newer-runners.yml
...eleased/fix-ci-requests-concurrency-for-newer-runners.yml
+3
-0
builds.rb
lib/ci/api/builds.rb
+11
-4
builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+14
-0
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 @
67b407b4
...
@@ -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 @
67b407b4
---
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 @
67b407b4
...
@@ -18,18 +18,20 @@ module Ci
...
@@ -18,18 +18,20 @@ 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?
if
result
.
build
Gitlab
::
Metrics
.
add_event
(
:build_found
,
Gitlab
::
Metrics
.
add_event
(
:build_found
,
project:
build
.
project
.
path_with_namespace
)
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
)
...
@@ -37,6 +39,11 @@ module Ci
...
@@ -37,6 +39,11 @@ module Ci
build_not_found!
build_not_found!
end
end
else
# We received build that is invalid due to concurrency conflict
Gitlab
::
Metrics
.
add_event
(
:build_invalid
)
conflict!
end
end
end
# Update an existing build - Runners only
# Update an existing build - Runners only
...
...
spec/requests/ci/api/builds_spec.rb
View file @
67b407b4
...
@@ -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 @
67b407b4
...
@@ -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