Commit 647106fe authored by Shinya Maeda's avatar Shinya Maeda

Check if trace exists before process `archive!` method

parent 9bf810a9
......@@ -6,7 +6,7 @@ class ArchiveTraceWorker
def perform(job_id)
Ci::Build.find_by(id: job_id).try do |job|
job.trace.archive!
job.trace.archive! unless build.job_artifacts_trace
end
end
end
......@@ -11,10 +11,8 @@ 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!
rescue ArchiveError => e
next if e.message.include?('Already archived')
build.trace.archive! unless build.job_artifacts_trace
rescue => e
failed_archive_counter.increment
Rails.logger.error "Failed to archive stale live trace. id: #{build.id} message: #{e.message}"
end
......
......@@ -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!
build.trace.archive! unless build.job_artifacts_trace
rescue => e
Rails.logger.error "Failed to archive live trace. id: #{build.id} message: #{e.message}"
end
......
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