2020-03-02 21:08:01 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Projects
|
2020-05-06 06:09:36 +00:00
|
|
|
class UpdateRepositoryStorageService
|
2020-12-17 18:10:14 +00:00
|
|
|
include UpdateRepositoryStorageMethods
|
2020-03-02 21:08:01 +00:00
|
|
|
|
2020-12-17 18:10:14 +00:00
|
|
|
delegate :project, to: :repository_storage_move
|
2020-03-02 21:08:01 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-12-17 18:10:14 +00:00
|
|
|
def track_repository(_destination_storage_name)
|
|
|
|
project.leave_pool_repository
|
|
|
|
project.track_project_repository
|
2020-04-14 00:09:57 +00:00
|
|
|
end
|
|
|
|
|
2020-05-06 06:09:36 +00:00
|
|
|
def mirror_repositories
|
2020-12-17 18:10:14 +00:00
|
|
|
mirror_repository(type: Gitlab::GlRepository::PROJECT) if project.repository_exists?
|
2020-03-02 21:08:01 +00:00
|
|
|
|
|
|
|
if project.wiki.repository_exists?
|
2020-05-06 06:09:36 +00:00
|
|
|
mirror_repository(type: Gitlab::GlRepository::WIKI)
|
2020-03-02 21:08:01 +00:00
|
|
|
end
|
2020-05-13 18:08:47 +00:00
|
|
|
|
|
|
|
if project.design_repository.exists?
|
|
|
|
mirror_repository(type: ::Gitlab::GlRepository::DESIGN)
|
|
|
|
end
|
2020-03-02 21:08:01 +00:00
|
|
|
end
|
|
|
|
|
2020-12-17 18:10:14 +00:00
|
|
|
# The underlying FetchInternalRemote call uses a `git fetch` to move data
|
|
|
|
# to the new repository, which leaves it in a less-well-packed state,
|
|
|
|
# lacking bitmaps and commit graphs. Housekeeping will boost performance
|
|
|
|
# significantly.
|
|
|
|
def enqueue_housekeeping
|
|
|
|
return unless Gitlab::CurrentSettings.housekeeping_enabled?
|
|
|
|
return unless Feature.enabled?(:repack_after_shard_migration, project)
|
2020-03-06 15:08:05 +00:00
|
|
|
|
2021-01-19 09:10:32 +00:00
|
|
|
Repositories::HousekeepingService.new(project, :gc).execute
|
|
|
|
rescue Repositories::HousekeepingService::LeaseTaken
|
2020-12-17 18:10:14 +00:00
|
|
|
# No action required
|
2020-03-02 21:08:01 +00:00
|
|
|
end
|
|
|
|
|
2020-08-13 12:09:50 +00:00
|
|
|
def remove_old_paths
|
2020-12-17 18:10:14 +00:00
|
|
|
super
|
2020-08-13 12:09:50 +00:00
|
|
|
|
|
|
|
if project.wiki.repository_exists?
|
|
|
|
Gitlab::Git::Repository.new(
|
|
|
|
source_storage_name,
|
|
|
|
"#{project.wiki.disk_path}.git",
|
|
|
|
nil,
|
|
|
|
nil
|
|
|
|
).remove
|
2020-03-02 21:08:01 +00:00
|
|
|
end
|
|
|
|
|
2020-08-13 12:09:50 +00:00
|
|
|
if project.design_repository.exists?
|
|
|
|
Gitlab::Git::Repository.new(
|
|
|
|
source_storage_name,
|
|
|
|
"#{project.design_repository.disk_path}.git",
|
|
|
|
nil,
|
|
|
|
nil
|
|
|
|
).remove
|
|
|
|
end
|
2020-03-02 21:08:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|