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
Léo-Paul Géneau
gitlab-ce
Commits
68d57939
Commit
68d57939
authored
Jul 04, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spec
parent
d86bed76
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
9 deletions
+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
No files found.
app/workers/archive_trace_worker.rb
View file @
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
View file @
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
View file @
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
View file @
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
...
...
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