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 ...@@ -6,7 +6,7 @@ class ArchiveTraceWorker
def perform(job_id) def perform(job_id)
Ci::Build.find_by(id: job_id).try do |job| Ci::Build.find_by(id: job_id).try do |job|
job.trace.archive! job.trace.archive! unless build.job_artifacts_trace
end end
end end
end end
...@@ -11,10 +11,8 @@ module Ci ...@@ -11,10 +11,8 @@ module Ci
# More details in https://gitlab.com/gitlab-org/gitlab-ce/issues/36791 # 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| Ci::Build.finished.with_live_trace.find_each(batch_size: 100) do |build|
begin begin
build.trace.archive! build.trace.archive! unless build.job_artifacts_trace
rescue ArchiveError => e rescue => e
next if e.message.include?('Already archived')
failed_archive_counter.increment failed_archive_counter.increment
Rails.logger.error "Failed to archive stale live trace. id: #{build.id} message: #{e.message}" Rails.logger.error "Failed to archive stale live trace. id: #{build.id} message: #{e.message}"
end end
......
...@@ -13,7 +13,7 @@ module Gitlab ...@@ -13,7 +13,7 @@ module Gitlab
::Ci::Build.finished.without_archived_trace ::Ci::Build.finished.without_archived_trace
.where(id: start_id..stop_id).find_each do |build| .where(id: start_id..stop_id).find_each do |build|
begin begin
build.trace.archive! build.trace.archive! unless build.job_artifacts_trace
rescue => e rescue => e
Rails.logger.error "Failed to archive live trace. id: #{build.id} message: #{e.message}" Rails.logger.error "Failed to archive live trace. id: #{build.id} message: #{e.message}"
end 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