diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2019-01-23 03:40:05 +0100 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2019-03-01 15:49:20 +0100 |
commit | fc0ff92807620c36d01f23eb0d7d88b02cb141c1 (patch) | |
tree | 8241564fc370782be698266bb14d5c1a69a1ded0 /app/workers | |
parent | d63380fa93dff921c69f7aaa31ff004864e4db13 (diff) | |
download | gitlab-ce-fc0ff92807620c36d01f23eb0d7d88b02cb141c1.tar.gz |
Added Rollbacker workers and support on the rake task
Rollback is done similar to Migration for the Hashed Storage.
It also shares the same ExclusiveLease key to prevent both happening
at the same time.
All Hashed Storage related workers now share the same queue namespace
which allows for assigning dedicated workers easily.
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/all_queues.yml | 1 | ||||
-rw-r--r-- | app/workers/hashed_storage/project_migrate_worker.rb | 4 | ||||
-rw-r--r-- | app/workers/hashed_storage/project_rollback_worker.rb | 4 | ||||
-rw-r--r-- | app/workers/hashed_storage/rollbacker_worker.rb | 16 |
4 files changed, 21 insertions, 4 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index a5dce221883..d86f654dd44 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -47,6 +47,7 @@ - github_importer:github_import_stage_import_repository - hashed_storage:hashed_storage_migrator +- hashed_storage:hashed_storage_rollbacker - hashed_storage:hashed_storage_project_migrate - hashed_storage:hashed_storage_project_rollback diff --git a/app/workers/hashed_storage/project_migrate_worker.rb b/app/workers/hashed_storage/project_migrate_worker.rb index 05bf72f519a..d516929129f 100644 --- a/app/workers/hashed_storage/project_migrate_worker.rb +++ b/app/workers/hashed_storage/project_migrate_worker.rb @@ -14,8 +14,8 @@ module HashedStorage uuid = lease_for(project_id).try_obtain if uuid - project = Project.find_by(id: project_id) - return if project.nil? || project.pending_delete? + project = Project.without_deleted.find_by(id: project_id) + return unless project old_disk_path ||= project.disk_path diff --git a/app/workers/hashed_storage/project_rollback_worker.rb b/app/workers/hashed_storage/project_rollback_worker.rb index ace9fea98a6..c6ac76a1674 100644 --- a/app/workers/hashed_storage/project_rollback_worker.rb +++ b/app/workers/hashed_storage/project_rollback_worker.rb @@ -13,8 +13,8 @@ module HashedStorage uuid = lease_for(project_id).try_obtain if uuid - project = Project.find_by(id: project_id) - return if project.nil? || project.pending_delete? + project = Project.without_deleted.find_by(id: project_id) + return unless project old_disk_path ||= project.disk_path diff --git a/app/workers/hashed_storage/rollbacker_worker.rb b/app/workers/hashed_storage/rollbacker_worker.rb new file mode 100644 index 00000000000..a4da8443787 --- /dev/null +++ b/app/workers/hashed_storage/rollbacker_worker.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module HashedStorage + class RollbackerWorker + include ApplicationWorker + + queue_namespace :hashed_storage + + # @param [Integer] start initial ID of the batch + # @param [Integer] finish last ID of the batch + def perform(start, finish) + migrator = Gitlab::HashedStorage::Migrator.new + migrator.bulk_rollback(start: start, finish: finish) + end + end +end |