Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
40644815
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,发现更多精彩内容 >>
提交
40644815
编写于
6月 01, 2018
作者:
S
Shinya Maeda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename find_stale_in_batches to find_builds_from_stale_live_trace. Fix comments
上级
2522691e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
14 deletion
+12
-14
app/models/ci/build_trace_chunk.rb
app/models/ci/build_trace_chunk.rb
+2
-2
app/workers/ci/rescue_stale_live_trace_worker.rb
app/workers/ci/rescue_stale_live_trace_worker.rb
+4
-6
spec/models/ci/build_trace_chunk_spec.rb
spec/models/ci/build_trace_chunk_spec.rb
+6
-6
未找到文件。
app/models/ci/build_trace_chunk.rb
浏览文件 @
40644815
...
...
@@ -52,13 +52,13 @@ module Ci
end
# Find stale live traces and return their build ids
def
find_
stale_in_batches
(
finished_before:
1
.
hour
.
ago
)
def
find_
builds_from_stale_live_trace
include
(
EachBatch
)
.
select
(
:build_id
)
.
group
(
:build_id
)
.
joins
(
:build
)
.
merge
(
Ci
::
Build
.
finished
)
.
where
(
'ci_builds.finished_at < ?'
,
finished_before
)
.
where
(
'ci_builds.finished_at < ?'
,
1
.
hour
.
ago
)
.
each_batch
(
column: :build_id
)
do
|
chunks
|
build_ids
=
chunks
.
map
{
|
chunk
|
chunk
.
build_id
}
...
...
app/workers/ci/rescue_stale_live_trace_worker.rb
浏览文件 @
40644815
...
...
@@ -4,12 +4,10 @@ module Ci
include
CronjobQueue
def
perform
# Reschedule to archive live traces
#
# The targets are jobs with the following conditions
# - Jobs had been finished 1 hour ago, but they don't have an archived trace yet
# This could happen when their sidekiq-jobs are lost by SIGKILL
Ci
::
BuildTraceChunk
.
find_stale_in_batches
(
finished_before:
1
.
hour
.
ago
)
do
|
build_ids
|
# Archive live traces which still resides in redis or database
# This could happen when sidekiq-jobs for archivements are lost by SIGKILL
# Issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/36791
Ci
::
BuildTraceChunk
.
find_builds_from_stale_live_trace
do
|
build_ids
|
Ci
::
Build
.
where
(
id:
build_ids
).
find_each
do
|
build
|
begin
build
.
trace
.
archive!
...
...
spec/models/ci/build_trace_chunk_spec.rb
浏览文件 @
40644815
...
...
@@ -35,8 +35,8 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
describe
'.find_
stale_in_batches
'
do
subject
{
described_class
.
find_
stale_in_batches
}
describe
'.find_
builds_from_stale_live_trace
'
do
subject
{
described_class
.
find_
builds_from_stale_live_trace
}
context
'when build status is finished'
do
context
'when build finished 2 days ago'
do
...
...
@@ -44,7 +44,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_artifact
,
finished_at:
2
.
days
.
ago
)
}
it
'does not yield build id'
do
expect
{
|
b
|
described_class
.
find_
stale_in_batches
(
&
b
)
}.
not_to
yield_control
expect
{
|
b
|
described_class
.
find_
builds_from_stale_live_trace
(
&
b
)
}.
not_to
yield_control
end
end
...
...
@@ -52,7 +52,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
,
finished_at:
2
.
days
.
ago
)
}
it
'yields build id'
do
expect
{
|
b
|
described_class
.
find_
stale_in_batches
(
&
b
)
}.
to
yield_with_args
([
build
.
id
])
expect
{
|
b
|
described_class
.
find_
builds_from_stale_live_trace
(
&
b
)
}.
to
yield_with_args
([
build
.
id
])
end
end
end
...
...
@@ -61,7 +61,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
,
finished_at:
10
.
minutes
.
ago
)
}
it
'does not yield build id'
do
expect
{
|
b
|
described_class
.
find_
stale_in_batches
(
&
b
)
}.
not_to
yield_control
expect
{
|
b
|
described_class
.
find_
builds_from_stale_live_trace
(
&
b
)
}.
not_to
yield_control
end
end
end
...
...
@@ -70,7 +70,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let!
(
:build
)
{
create
(
:ci_build
,
:running
,
:trace_live
)
}
it
'does not yield build id'
do
expect
{
|
b
|
described_class
.
find_
stale_in_batches
(
&
b
)
}.
not_to
yield_control
expect
{
|
b
|
described_class
.
find_
builds_from_stale_live_trace
(
&
b
)
}.
not_to
yield_control
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录