Commit ec8745d6 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'zj-improve-object-store-rake-task' into 'master'

Use proper logging for artifacts rake task

See merge request !2762
parents 5210cb3c 6af9c152
---
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