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
32c1501d
Commit
32c1501d
authored
Feb 26, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add rake task. Adopt the latest fix. Drop CreateTraceArtifactService
parent
f0d7a2ff
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
51 deletions
+50
-51
app/services/ci/create_trace_artifact_service.rb
app/services/ci/create_trace_artifact_service.rb
+0
-36
app/workers/archive_legacy_trace_worker.rb
app/workers/archive_legacy_trace_worker.rb
+10
-0
app/workers/create_trace_artifact_worker.rb
app/workers/create_trace_artifact_worker.rb
+1
-3
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+22
-12
lib/tasks/gitlab/traces.rake
lib/tasks/gitlab/traces.rake
+17
-0
No files found.
app/services/ci/create_trace_artifact_service.rb
deleted
100644 → 0
View file @
f0d7a2ff
module
Ci
class
CreateTraceArtifactService
<
BaseService
def
execute
(
job
)
return
if
job
.
job_artifacts_trace
job
.
trace
.
read
do
|
stream
|
break
unless
stream
.
file?
clone_file!
(
stream
.
path
,
JobArtifactUploader
.
workhorse_upload_path
)
do
|
clone_path
|
create_job_trace!
(
job
,
clone_path
)
FileUtils
.
rm
(
stream
.
path
)
end
end
end
private
def
create_job_trace!
(
job
,
path
)
File
.
open
(
path
)
do
|
stream
|
job
.
create_job_artifacts_trace!
(
project:
job
.
project
,
file_type: :trace
,
file:
stream
)
end
end
def
clone_file!
(
src_path
,
temp_dir
)
FileUtils
.
mkdir_p
(
temp_dir
)
Dir
.
mktmpdir
(
'tmp-trace'
,
temp_dir
)
do
|
dir_path
|
temp_path
=
File
.
join
(
dir_path
,
"job.log"
)
FileUtils
.
copy
(
src_path
,
temp_path
)
yield
(
temp_path
)
end
end
end
end
app/workers/archive_legacy_trace_worker.rb
0 → 100644
View file @
32c1501d
class
ArchiveLegacyTraceWorker
include
ApplicationWorker
include
ObjectStorageQueue
def
perform
(
job_id
)
Ci
::
Build
.
find_by
(
id:
job_id
).
try
do
|
job
|
job
.
trace
.
archive!
end
end
end
app/workers/create_trace_artifact_worker.rb
View file @
32c1501d
...
@@ -2,10 +2,8 @@ class CreateTraceArtifactWorker
...
@@ -2,10 +2,8 @@ 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
.
find_by
(
id:
job_id
).
try
do
|
job
|
job
.
trace
.
archive!
job
.
trace
.
archive!
end
end
end
end
...
...
lib/gitlab/ci/trace.rb
View file @
32c1501d
...
@@ -112,18 +112,28 @@ module Gitlab
...
@@ -112,18 +112,28 @@ module Gitlab
private
private
def
archive_stream!
(
stream
)
def
archive_stream!
(
stream
)
file
=
Tempfile
.
new
(
'trace.log'
)
clone_file!
(
stream
,
JobArtifactUploader
.
workhorse_upload_path
)
do
|
clone_path
|
size
=
IO
.
copy_stream
(
file
,
stream
)
create_job_trace!
(
job
,
clone_path
)
raise
'Not all saved'
unless
size
==
stream
.
size
end
file
.
close
end
job
.
create_job_artifacts_trace!
(
def
clone_file!
(
src_stream
,
temp_dir
)
project:
job
.
project
,
FileUtils
.
mkdir_p
(
temp_dir
)
file_type: :trace
,
Dir
.
mktmpdir
(
'tmp-trace'
,
temp_dir
)
do
|
dir_path
|
file:
file
)
temp_path
=
File
.
join
(
dir_path
,
"job.log"
)
ensure
size
=
IO
.
write
(
src_stream
,
temp_path
)
file
&
.
close
raise
'Not all saved'
unless
size
==
src_stream
.
size
file
&
.
unlink
yield
(
temp_path
)
end
end
def
create_job_trace!
(
job
,
path
)
File
.
open
(
path
)
do
|
stream
|
job
.
create_job_artifacts_trace!
(
project:
job
.
project
,
file_type: :trace
,
file:
stream
)
end
end
end
def
ensure_path
def
ensure_path
...
...
lib/tasks/gitlab/traces.rake
0 → 100644
View file @
32c1501d
require
'logger'
require
'resolv-replace'
desc
"GitLab | Archive legacy traces to trace artifacts"
namespace
:gitlab
do
namespace
:traces
do
task
archive: :environment
do
logger
=
Logger
.
new
(
STDOUT
)
logger
.
info
(
'Archiving legacy traces'
)
job_ids
=
Ci
::
Build
.
complete
.
without_trace_artifact
.
pluck
(
:id
)
job_ids
=
job_ids
.
map
{
|
build_id
|
[
build_id
]
}
ArchiveLegacyTraceWorker
.
bulk_perform_async
(
job_ids
)
end
end
end
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