2018-03-27 19:54:05 +05:30
|
|
|
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')
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
Ci::Build.finished.without_archived_trace
|
2018-03-27 19:54:05 +05:30
|
|
|
.order(id: :asc)
|
|
|
|
.find_in_batches(batch_size: 1000) do |jobs|
|
|
|
|
job_ids = jobs.map { |job| [job.id] }
|
|
|
|
|
|
|
|
ArchiveTraceWorker.bulk_perform_async(job_ids)
|
|
|
|
|
|
|
|
logger.info("Scheduled #{job_ids.count} jobs. From #{job_ids.min} to #{job_ids.max}")
|
|
|
|
end
|
|
|
|
end
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
task migrate: :environment do
|
|
|
|
logger = Logger.new(STDOUT)
|
|
|
|
logger.info('Starting transfer of job traces')
|
|
|
|
|
|
|
|
Ci::Build.joins(:project)
|
|
|
|
.with_archived_trace_stored_locally
|
|
|
|
.find_each(batch_size: 10) do |build|
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
build.job_artifacts_trace.file.migrate!(ObjectStorage::Store::REMOTE)
|
|
|
|
|
|
|
|
logger.info("Transferred job trace of #{build.id} to object storage")
|
|
|
|
rescue => e
|
|
|
|
logger.error("Failed to transfer artifacts of #{build.id} with error: #{e.message}")
|
2018-11-20 20:47:30 +05:30
|
|
|
end
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
end
|
|
|
|
end
|