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
end
def open
if file_storage?
File.open(path, "rb")
else
raise 'Only File System is supported'
end
raise 'Only File System is supported' unless file_storage?
File.open(path, "rb")
end
private
......
......@@ -7,6 +7,7 @@ class BuildFinishedWorker
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
BuildTraceSectionsWorker.perform_async(build.id)
CreateArtifactsTraceWorker.perform_async(build.id)
BuildCoverageWorker.new.perform(build.id)
BuildHooksWorker.new.perform(build.id)
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
put '/:id' do
job = authenticate_job!
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
job.trace.set(params[:trace]) if params[:trace]
Gitlab::Metrics.add_event(:update_build,
project: job.project.full_path)
......
......@@ -101,12 +101,6 @@ module Gitlab
job.erase_old_trace!
end
def current_path
@current_path ||= paths.find do |trace_path|
File.exist?(trace_path)
end
end
private
def ensure_path
......@@ -122,6 +116,12 @@ module Gitlab
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,
# 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