diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-08-16 14:28:47 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2018-08-16 14:28:47 +0000 |
commit | 63091cfe6432b2290f6ccd0c1e8105c8900b9df5 (patch) | |
tree | 16305434a011e1d1549f5b0016c88580f6ef2378 /lib/tasks | |
parent | e6da699e1598072784179dcc26fe08614945b025 (diff) | |
download | gitlab-ce-63091cfe6432b2290f6ccd0c1e8105c8900b9df5.tar.gz |
Add rake command to migrate archived traces from local storage to object storage
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/gitlab/traces.rake | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/traces.rake b/lib/tasks/gitlab/traces.rake index ddcca69711f..5a232091a7e 100644 --- a/lib/tasks/gitlab/traces.rake +++ b/lib/tasks/gitlab/traces.rake @@ -18,5 +18,22 @@ namespace :gitlab do logger.info("Scheduled #{job_ids.count} jobs. From #{job_ids.min} to #{job_ids.max}") end end + + 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| + begin + 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}") + end + end + end end end |