Send a Geo hashed migration event when migrating to hashed storage

parent 2307b35f
...@@ -27,7 +27,7 @@ module Geo ...@@ -27,7 +27,7 @@ module Geo
end end
def old_wiki_disk_path def old_wiki_disk_path
"#{old_disk_path}.wiki" params.fetch(:old_wiki_disk_path)
end end
end end
end end
...@@ -4,7 +4,7 @@ module Projects ...@@ -4,7 +4,7 @@ module Projects
prepend ::EE::Projects::HashedStorageMigrationService prepend ::EE::Projects::HashedStorageMigrationService
attr_reader :old_disk_path, :new_disk_path attr_reader :old_disk_path, :new_disk_path, :old_wiki_disk_path, :old_storage_version
def initialize(project, logger = nil) def initialize(project, logger = nil)
@project = project @project = project
...@@ -17,6 +17,7 @@ module Projects ...@@ -17,6 +17,7 @@ module Projects
@old_disk_path = project.disk_path @old_disk_path = project.disk_path
has_wiki = project.wiki.repository_exists? has_wiki = project.wiki.repository_exists?
@old_storage_version = project.storage_version
project.storage_version = Storage::HashedProject::STORAGE_VERSION project.storage_version = Storage::HashedProject::STORAGE_VERSION
project.ensure_storage_path_exists project.ensure_storage_path_exists
...@@ -25,7 +26,8 @@ module Projects ...@@ -25,7 +26,8 @@ module Projects
result = move_repository(@old_disk_path, @new_disk_path) result = move_repository(@old_disk_path, @new_disk_path)
if has_wiki if has_wiki
result &&= move_repository("#{@old_disk_path}.wiki", "#{@new_disk_path}.wiki") @old_wiki_disk_path = "#{@old_disk_path}.wiki"
result &&= move_repository(@old_wiki_disk_path, "#{@new_disk_path}.wiki")
end end
unless result unless result
......
...@@ -5,10 +5,11 @@ module EE ...@@ -5,10 +5,11 @@ module EE
raise NotImplementedError.new unless defined?(super) raise NotImplementedError.new unless defined?(super)
super do super do
::Geo::RepositoryRenamedEventStore.new( ::Geo::HashedStorageMigratedEventStore.new(
project, project,
old_path: File.basename(old_disk_path), old_storage_version: old_storage_version,
old_path_with_namespace: old_disk_path old_disk_path: old_disk_path,
old_wiki_disk_path: old_wiki_disk_path
).create ).create
end end
end end
......
...@@ -10,19 +10,19 @@ describe Projects::HashedStorageMigrationService do ...@@ -10,19 +10,19 @@ describe Projects::HashedStorageMigrationService do
set(:primary) { create(:geo_node, :primary) } set(:primary) { create(:geo_node, :primary) }
set(:secondary) { create(:geo_node) } set(:secondary) { create(:geo_node) }
it 'creates a Geo::RepositoryRenamedEvent on success' do it 'creates a Geo::HashedStorageMigratedEvent on success' do
expect { service.execute }.to change { Geo::EventLog.count }.by(1) expect { service.execute }.to change(Geo::EventLog, :count).by(1)
event = Geo::EventLog.first.event event = Geo::EventLog.first.event
expect(event).to be_a(Geo::RepositoryRenamedEvent) expect(event).to be_a(Geo::HashedStorageMigratedEvent)
expect(event).to have_attributes( expect(event).to have_attributes(
old_path: project.path, old_storage_version: nil,
new_path: project.path, new_storage_version: Storage::HashedProject::STORAGE_VERSION,
old_path_with_namespace: legacy_storage.disk_path, old_disk_path: legacy_storage.disk_path,
new_path_with_namespace: hashed_storage.disk_path, new_disk_path: hashed_storage.disk_path,
old_wiki_path_with_namespace: legacy_storage.disk_path + '.wiki', old_wiki_disk_path: legacy_storage.disk_path + '.wiki',
new_wiki_path_with_namespace: hashed_storage.disk_path + '.wiki' new_wiki_disk_path: hashed_storage.disk_path + '.wiki'
) )
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