Geo - Fix disk_path when replaying repository deleted events

parent b562f53a
module Geo module Geo
class RepositoryDestroyService class RepositoryDestroyService
attr_reader :id, :name, :full_path, :storage_name attr_reader :id, :name, :disk_path, :storage_name
def initialize(id, name, full_path, storage_name) def initialize(id, name, disk_path, storage_name)
@id = id @id = id
@name = name @name = name
@full_path = full_path @disk_path = disk_path
@storage_name = storage_name @storage_name = storage_name
end end
def async_execute def async_execute
GeoRepositoryDestroyWorker.perform_async(id, name, full_path, storage_name) GeoRepositoryDestroyWorker.perform_async(id, name, disk_path, storage_name)
end end
def execute def execute
...@@ -24,7 +24,7 @@ module Geo ...@@ -24,7 +24,7 @@ module Geo
# rebuilding only what our service class requires # rebuilding only what our service class requires
::Geo::DeletedProject.new(id: id, ::Geo::DeletedProject.new(id: id,
name: name, name: name,
full_path: full_path, full_path: disk_path,
repository_storage: storage_name) repository_storage: storage_name)
end end
end end
......
...@@ -3,7 +3,7 @@ class GeoRepositoryDestroyWorker ...@@ -3,7 +3,7 @@ class GeoRepositoryDestroyWorker
include GeoQueue include GeoQueue
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
def perform(id, name, full_path, storage_name) def perform(id, name, disk_path, storage_name)
Geo::RepositoryDestroyService.new(id, name, full_path, storage_name).execute Geo::RepositoryDestroyService.new(id, name, disk_path, storage_name).execute
end end
end end
...@@ -122,17 +122,17 @@ module Gitlab ...@@ -122,17 +122,17 @@ module Gitlab
def handle_repository_deleted(event_log) def handle_repository_deleted(event_log)
event = event_log.repository_deleted_event event = event_log.repository_deleted_event
disk_path = File.join(event.repository_storage_path, event.deleted_path)
job_id = ::Geo::RepositoryDestroyService job_id = ::Geo::RepositoryDestroyService
.new(event.project_id, event.deleted_project_name, disk_path, event.repository_storage_name) .new(event.project_id, event.deleted_project_name, event.deleted_path, event.repository_storage_name)
.async_execute .async_execute
logger.event_info( logger.event_info(
event_log.created_at, event_log.created_at,
message: 'Deleted project', message: 'Deleted project',
project_id: event.project_id, project_id: event.project_id,
disk_path: disk_path, repository_storage_name: event.repository_storage_name,
disk_path: event.deleted_path,
job_id: job_id) job_id: job_id)
# No need to create a project entry if it doesn't exist # No need to create a project entry if it doesn't exist
......
...@@ -150,11 +150,10 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared ...@@ -150,11 +150,10 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared
it 'schedules a GeoRepositoryDestroyWorker' do it 'schedules a GeoRepositoryDestroyWorker' do
project_id = repository_deleted_event.project_id project_id = repository_deleted_event.project_id
project_name = repository_deleted_event.deleted_project_name project_name = repository_deleted_event.deleted_project_name
full_path = File.join(repository_deleted_event.repository_storage_path, project_path = repository_deleted_event.deleted_path
repository_deleted_event.deleted_path)
expect(::GeoRepositoryDestroyWorker).to receive(:perform_async) expect(::GeoRepositoryDestroyWorker).to receive(:perform_async)
.with(project_id, project_name, full_path, project.repository_storage) .with(project_id, project_name, project_path, project.repository_storage)
daemon.run_once! daemon.run_once!
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