Commit 6af9c152 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Use proper logging for artifacts rake task

Using logging we get a known structure, and the time of the message.
Last change removed the unused `order` statement. This is not used
because `find_each` uses the primary key anyway.
parent bab59bce
---
title: Use a logger for the artifacts migration rake task
merge_request:
author:
type: changed
require 'logger'
desc "GitLab | Migrate files for artifacts to comply with new storage format"
namespace :gitlab do
namespace :artifacts do
task migrate: :environment do
puts 'Artifacts'.color(:yellow)
logger = Logger.new(STDOUT)
logger.info('Starting transfer of artifacts')
Ci::Build.joins(:project)
.with_artifacts
.order(id: :asc)
.where(artifacts_file_store: [nil, ArtifactUploader::LOCAL_STORE])
.find_each(batch_size: 10) do |build|
begin
print "Migrating job #{build.id} of size #{build.artifacts_size.to_i.bytes} to remote storage... "
build.artifacts_file.migrate!(ArtifactUploader::REMOTE_STORE)
build.artifacts_metadata.migrate!(ArtifactUploader::REMOTE_STORE)
puts "OK".color(:green)
logger.info("Transferred artifacts of #{build.id} of #{build.artifacts_size} to object storage")
rescue => e
puts "Failed: #{e.message}".color(:red)
logger.error("Failed to transfer artifacts of #{build.id} with error: #{e.message}")
end
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