Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2018-12-22 16:54:33 +0300
committerGabriel Mazetto <brodock@gmail.com>2019-01-25 22:26:35 +0300
commitc2c34eba62f26bed8cad8b07934e14b4519eef7c (patch)
treeb5ab373fc66274e4a902ff828f1ba460300d30fa /lib/gitlab/hashed_storage
parent07a196be3dca5125454262bb96967d5895081c56 (diff)
Prepare rake task for storage rollback
We are keeping compatibility with existing scheduled jobs.
Diffstat (limited to 'lib/gitlab/hashed_storage')
-rw-r--r--lib/gitlab/hashed_storage/migrator.rb29
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/gitlab/hashed_storage/migrator.rb b/lib/gitlab/hashed_storage/migrator.rb
index 1f29cf10cad..4794b1978db 100644
--- a/lib/gitlab/hashed_storage/migrator.rb
+++ b/lib/gitlab/hashed_storage/migrator.rb
@@ -11,10 +11,11 @@ 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
+ # @param [Symbol] operation [:migrate, :rollback]
+ def bulk_schedule(start:, finish:, operation: :migrate)
+ StorageMigratorWorker.perform_async(start, finish, operation)
end
# Start migration of projects from specified range
@@ -22,21 +23,27 @@ module Gitlab
# 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
+ # @param [Symbol] operation [:migrate, :rollback]
# rubocop: disable CodeReuse/ActiveRecord
- def bulk_migrate(start, finish)
+ def bulk_migrate(start:, finish:, operation: :migrate)
projects = build_relation(start, finish)
projects.with_route.find_each(batch_size: BATCH_SIZE) do |project|
- migrate(project)
+ case operation
+ when :migrate
+ migrate(project)
+ when :rollback
+ rollback(project)
+ end
end
end
# rubocop: enable CodeReuse/ActiveRecord
# Flag a project to be migrated
#
- # @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 +52,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