Commit 7b85f67a authored by Gabriel Mazetto's avatar Gabriel Mazetto

Fixes and improve Repository Storage Migration

parent c94f3da8
module Geo
class HashedStorageMigrationService
include ::Gitlab::Geo::LogHelpers
attr_reader :project_id, :old_disk_path, :new_disk_path, :old_storage_version
def initialize(project_id, old_disk_path:, new_disk_path:, old_storage_version:)
......@@ -22,9 +24,12 @@ module Geo
project.expire_caches_before_rename(old_disk_path)
if migrating_from_legacy_storage? && !move_repository
log_error("Repository could not be migrated to Hashed Storage", project_id: project.id, source: old_disk_path, target: new_disk_path)
raise RepositoryCannotBeRenamed, "Repository #{old_disk_path} could not be renamed to #{new_disk_path}"
end
log_info("Repository migrated to Hashed Storage", project_id: project.id, source: old_disk_path, target: new_disk_path)
true
end
......
......@@ -82,7 +82,7 @@ FactoryGirl.define do
new_disk_path { project.path_with_namespace + '_new' }
old_wiki_disk_path { project.wiki.path_with_namespace }
new_wiki_disk_path { project.wiki.path_with_namespace + '_new' }
new_storage_version { Project::LATEST_STORAGE_VERSION }
new_storage_version { Project::HASHED_STORAGE_FEATURES[:repository] }
end
factory :geo_hashed_storage_attachments_event, class: Geo::HashedStorageAttachmentsEvent do
......
......@@ -10,7 +10,7 @@ describe Geo::HashedStorageMigrationService do
describe '#execute' do
context 'project backed by legacy storage' do
before do
project.update_attribute(:storage_version, Project::LATEST_STORAGE_VERSION)
project.update_attribute(:storage_version, Project::HASHED_STORAGE_FEATURES[:repository])
end
it 'moves the project repositories' do
......
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