summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2018-12-22 14:54:33 +0100
committerGabriel Mazetto <brodock@gmail.com>2019-03-01 15:49:20 +0100
commitff2ca3569e704bb26c770ba5c28a888789d27230 (patch)
treee4ec9d67040445700b2265aef0c7a9c047fdfae0
parent4471ab81c8484d9942183bd8114a757b8630b8ec (diff)
downloadgitlab-ce-ff2ca3569e704bb26c770ba5c28a888789d27230.tar.gz
Rake task for storage rollback
-rw-r--r--lib/tasks/gitlab/storage.rake45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/storage.rake b/lib/tasks/gitlab/storage.rake
index f9ce3e1d338..b759a2dad3a 100644
--- a/lib/tasks/gitlab/storage.rake
+++ b/lib/tasks/gitlab/storage.rake
@@ -45,6 +45,51 @@ namespace :gitlab do
puts ' Done!'
end
+ desc 'GitLab | Storage | Rollback existing projects to Legacy Storage'
+ task rollback_to_legacy: :environment do
+ if Gitlab::Database.read_only?
+ warn 'This task requires database write access. Exiting.'
+
+ next
+ end
+
+ storage_migrator = Gitlab::HashedStorage::Migrator.new
+ helper = Gitlab::HashedStorage::RakeHelper
+
+ if helper.range_single_item?
+ project = Project.with_storage_feature(:repository).find_by(id: helper.range_from)
+
+ unless project
+ warn "There are no projects that can be rolledback with ID=#{helper.range_from}"
+
+ next
+ end
+
+ puts "Enqueueing storage rollback of #{project.full_path} (ID=#{project.id})..."
+ storage_migrator.rollback(project)
+
+ next
+ end
+
+ hashed_projects_count = Project.with_storage_feature(:repository).count
+
+ if hashed_projects_count == 0
+ warn 'There are no projects that can have storage rolledback. Nothing to do!'
+
+ next
+ end
+
+ print "Enqueuing rollback of #{hashed_projects_count} projects in batches of #{helper.batch_size}"
+
+ helper.project_id_batches do |start, finish|
+ storage_migrator.bulk_schedule(start: start, finish: finish, operation: :rollback)
+
+ print '.'
+ end
+
+ puts ' Done!'
+ end
+
desc 'Gitlab | Storage | Summary of existing projects using Legacy Storage'
task legacy_projects: :environment do
helper = Gitlab::HashedStorage::RakeHelper