Add schedule bulk service and worker

In this commit we introduce the service and worker that
will allow us to move groups' repository storage in
bulk.

This classes will only be used through the API.
parent 427d48e1
......@@ -160,6 +160,8 @@
- 1
- - group_wikis_git_garbage_collect
- 1
- - groups_schedule_bulk_repository_shard_moves
- 1
- - groups_update_repository_storage
- 1
- - hashed_storage
......
# frozen_string_literal: true
class GroupWikiRepository < ApplicationRecord
include EachBatch
include Shardable
belongs_to :group
......
# frozen_string_literal: true
module Groups
# Tries to schedule a move for every group wiki with repositories on the source shard
class ScheduleBulkRepositoryShardMovesService
include ScheduleBulkRepositoryShardMovesMethods
extend ::Gitlab::Utils::Override
private
override :repository_klass
def repository_klass
GroupWikiRepository
end
override :container_klass
def container_klass
Group
end
override :container_column
def container_column
:group_id
end
override :schedule_bulk_worker_klass
def self.schedule_bulk_worker_klass
::Groups::ScheduleBulkRepositoryShardMovesWorker
end
end
end
......@@ -773,6 +773,14 @@
:weight: 1
:idempotent:
:tags: []
- :name: groups_schedule_bulk_repository_shard_moves
:feature_category: :gitaly
:has_external_dependencies:
:urgency: :throttled
:resource_boundary: :unknown
:weight: 1
:idempotent: true
:tags: []
- :name: groups_update_repository_storage
:feature_category: :gitaly
:has_external_dependencies:
......
# frozen_string_literal: true
module Groups
class ScheduleBulkRepositoryShardMovesWorker
include ApplicationWorker
idempotent!
feature_category :gitaly
urgency :throttled
def perform(source_storage_name, destination_storage_name = nil)
Groups::ScheduleBulkRepositoryShardMovesService.new.execute(source_storage_name, destination_storage_name)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Groups::ScheduleBulkRepositoryShardMovesService do
it_behaves_like 'moves repository shard in bulk' do
let_it_be_with_reload(:container) { create(:group, :wiki_repo) }
let(:move_service_klass) { Groups::RepositoryStorageMove }
let(:bulk_worker_klass) { Groups::ScheduleBulkRepositoryShardMovesWorker }
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Groups::ScheduleBulkRepositoryShardMovesWorker do
it_behaves_like 'schedules bulk repository shard moves' do
let_it_be_with_reload(:container) { create(:group, :wiki_repo) }
let(:move_service_klass) { Groups::RepositoryStorageMove }
let(:worker_klass) { Groups::UpdateRepositoryStorageWorker }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment