Commit 5f6d8261 authored by Shinya Maeda's avatar Shinya Maeda

Add CreateArtifactsTraceWorker

parent 002f314f
module Ci
class CreateArtifactsTraceService < BaseService
def execute(job_id)
Ci::Build.find_by(id: job_id).try do |job|
return if job.job_artifacts_trace
job.trace.read do |stream|
job.create_job_artifacts_trace!(
project: job.project,
file_type: :trace,
file: stream.path) if stream.file?
end
end
end
end
end
...@@ -14,11 +14,9 @@ class JobArtifactUploader < GitlabUploader ...@@ -14,11 +14,9 @@ class JobArtifactUploader < GitlabUploader
end end
def open def open
if file_storage? raise 'Only File System is supported' unless file_storage?
File.open(path, "rb")
else File.open(path, "rb")
raise 'Only File System is supported'
end
end end
private private
......
...@@ -7,6 +7,7 @@ class BuildFinishedWorker ...@@ -7,6 +7,7 @@ class BuildFinishedWorker
def perform(build_id) def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build| Ci::Build.find_by(id: build_id).try do |build|
BuildTraceSectionsWorker.perform_async(build.id) BuildTraceSectionsWorker.perform_async(build.id)
CreateArtifactsTraceWorker.perform_async(build.id)
BuildCoverageWorker.new.perform(build.id) BuildCoverageWorker.new.perform(build.id)
BuildHooksWorker.new.perform(build.id) BuildHooksWorker.new.perform(build.id)
end end
......
class CreateArtifactsTraceWorker
include ApplicationWorker
include PipelineQueue
def perform(job_id)
Ci::CreateArtifactsTraceService.new.execute(job_id)
end
end
...@@ -120,16 +120,7 @@ module API ...@@ -120,16 +120,7 @@ module API
put '/:id' do put '/:id' do
job = authenticate_job! job = authenticate_job!
if params[:trace] job.trace.set(params[:trace]) if params[:trace]
# Overwrite live-trace by full-trace
job.trace.set(params[:trace])
# Move full-trace to JobArtifactUploader#default_path
job.build_job_artifacts_trace(
project: job.project,
file_type: :trace,
file: UploadedFile.new(job.trace.current_path, 'trace.log'))
end
Gitlab::Metrics.add_event(:update_build, Gitlab::Metrics.add_event(:update_build,
project: job.project.full_path) project: job.project.full_path)
......
...@@ -101,12 +101,6 @@ module Gitlab ...@@ -101,12 +101,6 @@ module Gitlab
job.erase_old_trace! job.erase_old_trace!
end end
def current_path
@current_path ||= paths.find do |trace_path|
File.exist?(trace_path)
end
end
private private
def ensure_path def ensure_path
...@@ -122,6 +116,12 @@ module Gitlab ...@@ -122,6 +116,12 @@ module Gitlab
end end
end end
def current_path
@current_path ||= paths.find do |trace_path|
File.exist?(trace_path)
end
end
## ##
# This method doesn't include the latest path, which is JobArtifactUploader#default_path, # This method doesn't include the latest path, which is JobArtifactUploader#default_path,
# Because, in EE, traces can be moved to ObjectStorage, so checking paths in Filestorage doesn't make sense. # Because, in EE, traces can be moved to ObjectStorage, so checking paths in Filestorage doesn't make sense.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment