From c4668c388f8da13ed3328c809a679a2542fd5b8d Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Mon, 17 Sep 2018 21:42:10 +0530 Subject: [PATCH] Add wrapper rake task to migrate all uploads to OS Add a rake task that will trigger gitlab:uploads:migrate rake task with different possible arguments, one by one. --- ...1-wrapper-rake-task-uploads-migrate-os.yml | 5 ++++ lib/tasks/gitlab/uploads/migrate.rake | 26 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/51571-wrapper-rake-task-uploads-migrate-os.yml diff --git a/changelogs/unreleased/51571-wrapper-rake-task-uploads-migrate-os.yml b/changelogs/unreleased/51571-wrapper-rake-task-uploads-migrate-os.yml new file mode 100644 index 00000000000..50710ca0aa8 --- /dev/null +++ b/changelogs/unreleased/51571-wrapper-rake-task-uploads-migrate-os.yml @@ -0,0 +1,5 @@ +--- +title: Add wrapper rake task to migrate all uploads to OS +merge_request: 21779 +author: +type: other diff --git a/lib/tasks/gitlab/uploads/migrate.rake b/lib/tasks/gitlab/uploads/migrate.rake index f548a266b99..1c93609a006 100644 --- a/lib/tasks/gitlab/uploads/migrate.rake +++ b/lib/tasks/gitlab/uploads/migrate.rake @@ -1,6 +1,30 @@ namespace :gitlab do namespace :uploads do - desc 'GitLab | Uploads | Migrate the uploaded files to object storage' + namespace :migrate do + desc "GitLab | Uploads | Migrate all uploaded files to object storage" + task all: :environment do + categories = [%w(AvatarUploader Project :avatar), + %w(AvatarUploader Group :avatar), + %w(AvatarUploader User :avatar), + %w(AttachmentUploader Note :attachment), + %w(AttachmentUploader Appearance :logo), + %w(AttachmentUploader Appearance :header_logo), + %w(FaviconUploader Appearance :favicon), + %w(FileUploader Project), + %w(PersonalFileUploader Snippet), + %w(NamespaceFileUploader Snippet), + %w(FileUploader MergeRequest)] + + categories.each do |args| + Rake::Task["gitlab:uploads:migrate"].invoke(*args) + Rake::Task["gitlab:uploads:migrate"].reenable + end + end + end + + # The following is the actual rake task that migrates uploads of specified + # category to object storage + desc 'GitLab | Uploads | Migrate the uploaded files of specified type to object storage' task :migrate, [:uploader_class, :model_class, :mounted_as] => :environment do |task, args| batch_size = ENV.fetch('BATCH', 200).to_i @to_store = ObjectStorage::Store::REMOTE -- GitLab