diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2019-01-17 02:53:50 +0100 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2019-01-25 20:26:35 +0100 |
commit | 7bc16889df458865ffbbb7bef8087c04a5768a1d (patch) | |
tree | 23842ae1d6de742eb8064f196e39dd90c179bd7c /lib | |
parent | b88f27c8d1cb44201490bf51db143f4267735775 (diff) | |
download | gitlab-ce-7bc16889df458865ffbbb7bef8087c04a5768a1d.tar.gz |
Refactor Storage Migration
Specs were reviewed and improved to better cover the current behavior.
There was some standardization done as well to facilitate the
implementation of the rollback functionality.
StorageMigratorWorker was extracted to HashedStorage namespace were
RollbackerWorker will live one as well.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/hashed_storage/migrator.rb | 19 | ||||
-rw-r--r-- | lib/tasks/gitlab/storage.rake | 2 |
2 files changed, 7 insertions, 14 deletions
diff --git a/lib/gitlab/hashed_storage/migrator.rb b/lib/gitlab/hashed_storage/migrator.rb index 4794b1978db..bf463077dcc 100644 --- a/lib/gitlab/hashed_storage/migrator.rb +++ b/lib/gitlab/hashed_storage/migrator.rb @@ -13,35 +13,28 @@ module Gitlab # # @param [Integer] start first project id for the range # @param [Integer] finish last project id for the range - # @param [Symbol] operation [:migrate, :rollback] - def bulk_schedule(start:, finish:, operation: :migrate) - StorageMigratorWorker.perform_async(start, finish, operation) + def bulk_schedule(start:, finish:) + ::HashedStorage::MigratorWorker.perform_async(start, finish) end # Start migration of projects from specified range # - # Flagging a project to be migrated is a synchronous action, + # Flagging a project to be migrated is a synchronous action # but the migration runs through async jobs # # @param [Integer] start first project id for the range # @param [Integer] finish last project id for the range - # @param [Symbol] operation [:migrate, :rollback] # rubocop: disable CodeReuse/ActiveRecord - def bulk_migrate(start:, finish:, operation: :migrate) + def bulk_migrate(start:, finish:) projects = build_relation(start, finish) projects.with_route.find_each(batch_size: BATCH_SIZE) do |project| - case operation - when :migrate - migrate(project) - when :rollback - rollback(project) - end + migrate(project) end end # rubocop: enable CodeReuse/ActiveRecord - # Flag a project to be migrated + # Flag a project to be migrated to Hashed Storage # # @param [Project] project that will be migrated def migrate(project) diff --git a/lib/tasks/gitlab/storage.rake b/lib/tasks/gitlab/storage.rake index 8212be90b97..f9ce3e1d338 100644 --- a/lib/tasks/gitlab/storage.rake +++ b/lib/tasks/gitlab/storage.rake @@ -37,7 +37,7 @@ namespace :gitlab do print "Enqueuing migration of #{legacy_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: :migrate) + storage_migrator.bulk_schedule(start: start, finish: finish) print '.' end |