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
Boxiang Sun
gitlab-ce
Commits
f0d7a2ff
Commit
f0d7a2ff
authored
Feb 23, 2018
by
Kamil Trzciński
Committed by
Shinya Maeda
Mar 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proper fix for artifacts trace migration which is fully safe
parent
fa31559a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
app/workers/create_trace_artifact_worker.rb
app/workers/create_trace_artifact_worker.rb
+3
-1
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+31
-0
No files found.
app/workers/create_trace_artifact_worker.rb
View file @
f0d7a2ff
...
@@ -2,9 +2,11 @@ class CreateTraceArtifactWorker
...
@@ -2,9 +2,11 @@ class CreateTraceArtifactWorker
include
ApplicationWorker
include
ApplicationWorker
include
PipelineQueue
include
PipelineQueue
# TODO: this worker should use BackgroundMigration or ObjectStorage queue
def
perform
(
job_id
)
def
perform
(
job_id
)
Ci
::
Build
.
preload
(
:project
,
:user
).
find_by
(
id:
job_id
).
try
do
|
job
|
Ci
::
Build
.
preload
(
:project
,
:user
).
find_by
(
id:
job_id
).
try
do
|
job
|
Ci
::
CreateTraceArtifactService
.
new
(
job
.
project
,
job
.
user
).
execute
(
job
)
job
.
trace
.
archive!
end
end
end
end
end
end
lib/gitlab/ci/trace.rb
View file @
f0d7a2ff
...
@@ -93,8 +93,39 @@ module Gitlab
...
@@ -93,8 +93,39 @@ module Gitlab
job
.
erase_old_trace!
job
.
erase_old_trace!
end
end
def
archive!
return
if
trace_artifact
if
current_path
File
.
open
(
current_path
)
do
|
f
|
archive_stream!
(
f
)
f
.
unlink
end
elsif
old_trace
StringIO
(
old_trace
).
tap
do
|
stream
|
archive_stream!
(
stream
)
job
.
erase_old_trace!
end
end
end
private
private
def
archive_stream!
(
stream
)
file
=
Tempfile
.
new
(
'trace.log'
)
size
=
IO
.
copy_stream
(
file
,
stream
)
raise
'Not all saved'
unless
size
==
stream
.
size
file
.
close
job
.
create_job_artifacts_trace!
(
project:
job
.
project
,
file_type: :trace
,
file:
file
)
ensure
file
&
.
close
file
&
.
unlink
end
def
ensure_path
def
ensure_path
return
current_path
if
current_path
return
current_path
if
current_path
...
...
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