summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-01-25 20:43:37 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-01-25 20:43:37 +0000
commit5f6f0cd6956db1349234ea1aea47776dffb2cfe4 (patch)
treed29f13f836f710a60f2f7b30fb1951112e0ad676 /lib
parent1d0580d4dca8133efe8b6035ead4455e7b1b40c5 (diff)
parent41712ebe0b22913c6fb844e62c77dc666b0b06a2 (diff)
downloadgitlab-ce-5f6f0cd6956db1349234ea1aea47776dffb2cfe4.tar.gz
Merge branch '53966-refactor-hashed-storage' into 'master'
Refactor Hashed Storage for future Rollback functionality See merge request gitlab-org/gitlab-ce!24402
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/hashed_storage/migrator.rb24
-rw-r--r--lib/tasks/gitlab/storage.rake2
2 files changed, 15 insertions, 11 deletions
diff --git a/lib/gitlab/hashed_storage/migrator.rb b/lib/gitlab/hashed_storage/migrator.rb
index 1f29cf10cad..bf463077dcc 100644
--- a/lib/gitlab/hashed_storage/migrator.rb
+++ b/lib/gitlab/hashed_storage/migrator.rb
@@ -11,21 +11,21 @@ module Gitlab
# Schedule a range of projects to be bulk migrated with #bulk_migrate asynchronously
#
- # @param [Object] start first project id for the range
- # @param [Object] finish last project id for the range
- def bulk_schedule(start, finish)
- StorageMigratorWorker.perform_async(start, finish)
+ # @param [Integer] start first project id for the range
+ # @param [Integer] finish last project id for the range
+ 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 [Object] start first project id for the range
- # @param [Object] finish last project id for the range
+ # @param [Integer] start first project id for the range
+ # @param [Integer] finish last project id for the range
# rubocop: disable CodeReuse/ActiveRecord
- def bulk_migrate(start, finish)
+ def bulk_migrate(start:, finish:)
projects = build_relation(start, finish)
projects.with_route.find_each(batch_size: BATCH_SIZE) do |project|
@@ -34,9 +34,9 @@ module Gitlab
end
# rubocop: enable CodeReuse/ActiveRecord
- # Flag a project to be migrated
+ # Flag a project to be migrated to Hashed Storage
#
- # @param [Object] project that will be migrated
+ # @param [Project] project that will be migrated
def migrate(project)
Rails.logger.info "Starting storage migration of #{project.full_path} (ID=#{project.id})..."
@@ -45,6 +45,10 @@ module Gitlab
Rails.logger.error("#{err.message} migrating storage of #{project.full_path} (ID=#{project.id}), trace - #{err.backtrace}")
end
+ def rollback(project)
+ # TODO: implement rollback strategy
+ end
+
private
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/lib/tasks/gitlab/storage.rake b/lib/tasks/gitlab/storage.rake
index 09dc3aa9882..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, finish)
+ storage_migrator.bulk_schedule(start: start, finish: finish)
print '.'
end