Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
68d57939
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,发现更多精彩内容 >>
提交
68d57939
编写于
7月 04, 2018
作者:
S
Shinya Maeda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix spec
上级
d86bed76
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
9 deletion
+23
-9
app/workers/archive_trace_worker.rb
app/workers/archive_trace_worker.rb
+2
-2
app/workers/ci/archive_traces_cron_worker.rb
app/workers/ci/archive_traces_cron_worker.rb
+3
-1
lib/gitlab/background_migration/archive_legacy_traces.rb
lib/gitlab/background_migration/archive_legacy_traces.rb
+1
-1
spec/workers/ci/archive_traces_cron_worker_spec.rb
spec/workers/ci/archive_traces_cron_worker_spec.rb
+17
-5
未找到文件。
app/workers/archive_trace_worker.rb
浏览文件 @
68d57939
...
...
@@ -5,8 +5,8 @@ class ArchiveTraceWorker
include
PipelineBackgroundQueue
def
perform
(
job_id
)
Ci
::
Build
.
find_by
(
id:
job_id
).
try
do
|
job
|
job
.
trace
.
archive!
unless
job
.
job_artifacts_trace
Ci
::
Build
.
without_archived_trace
.
find_by
(
id:
job_id
).
try
do
|
job
|
job
.
trace
.
archive!
end
end
end
app/workers/ci/archive_traces_cron_worker.rb
浏览文件 @
68d57939
...
...
@@ -11,8 +11,10 @@ module Ci
# More details in https://gitlab.com/gitlab-org/gitlab-ce/issues/36791
Ci
::
Build
.
finished
.
with_live_trace
.
find_each
(
batch_size:
100
)
do
|
build
|
begin
build
.
trace
.
archive!
unless
build
.
job_artifacts_trace
build
.
trace
.
archive!
rescue
=>
e
next
if
e
.
message
.
include?
(
'Already archived'
)
failed_archive_counter
.
increment
Rails
.
logger
.
error
"Failed to archive stale live trace. id:
#{
build
.
id
}
message:
#{
e
.
message
}
"
end
...
...
lib/gitlab/background_migration/archive_legacy_traces.rb
浏览文件 @
68d57939
...
...
@@ -13,7 +13,7 @@ module Gitlab
::
Ci
::
Build
.
finished
.
without_archived_trace
.
where
(
id:
start_id
..
stop_id
).
find_each
do
|
build
|
begin
build
.
trace
.
archive!
unless
build
.
job_artifacts_trace
build
.
trace
.
archive!
rescue
=>
e
Rails
.
logger
.
error
"Failed to archive live trace. id:
#{
build
.
id
}
message:
#{
e
.
message
}
"
end
...
...
spec/workers/ci/archive_traces_cron_worker_spec.rb
浏览文件 @
68d57939
...
...
@@ -25,24 +25,36 @@ describe Ci::ArchiveTracesCronWorker do
end
end
context
'when a job
was
succeeded'
do
context
'when a job succeeded'
do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
)
}
it_behaves_like
'archives trace'
context
'when a
rchive raised an exception
'
do
context
'when a
trace had already been archived
'
do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_artifact
,
:trace_live
)
}
let!
(
:build2
)
{
create
(
:ci_build
,
:success
,
:trace_live
)
}
it
'archives valid targets'
do
expect
(
Rails
.
logger
).
to
receive
(
:error
).
with
(
"Failed to archive stale live trace. id:
#{
build
.
id
}
message: Already archived"
)
it
'continues to archive live traces'
do
subject
build2
.
reload
expect
(
build2
.
job_artifacts_trace
).
to
be_exist
end
end
context
'when an unexpected exception happened during archiving'
do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
)
}
before
do
allow_any_instance_of
(
Gitlab
::
Ci
::
Trace
).
to
receive
(
:archive!
).
and_raise
(
'Unexpected error'
)
end
it
'puts a log'
do
expect
(
Rails
.
logger
).
to
receive
(
:error
).
with
(
"Failed to archive stale live trace. id:
#{
build
.
id
}
message: Unexpected error"
)
subject
end
end
end
context
'when a job was cancelled'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录