Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
637894de
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
637894de
编写于
1月 25, 2017
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix-ci-requests-concurrency' into 'master'
Fix CI requests concurrency See merge request !8760
上级
6cfe60df
31be74c7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
12 deletion
+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
未找到文件。
app/services/ci/register_build_service.rb
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录