Geo - Fix disk_path when replaying repository deleted events

parent b562f53a
module Geo
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
@name = name
@full_path = full_path
@disk_path = disk_path
@storage_name = storage_name
end
def async_execute
GeoRepositoryDestroyWorker.perform_async(id, name, full_path, storage_name)
GeoRepositoryDestroyWorker.perform_async(id, name, disk_path, storage_name)
end
def execute
......@@ -24,7 +24,7 @@ module Geo
# rebuilding only what our service class requires
::Geo::DeletedProject.new(id: id,
name: name,
full_path: full_path,
full_path: disk_path,
repository_storage: storage_name)
end
end
......
......@@ -3,7 +3,7 @@ class GeoRepositoryDestroyWorker
include GeoQueue
include Gitlab::ShellAdapter
def perform(id, name, full_path, storage_name)
Geo::RepositoryDestroyService.new(id, name, full_path, storage_name).execute
def perform(id, name, disk_path, storage_name)
Geo::RepositoryDestroyService.new(id, name, disk_path, storage_name).execute
end
end
......@@ -122,17 +122,17 @@ module Gitlab
def handle_repository_deleted(event_log)
event = event_log.repository_deleted_event
disk_path = File.join(event.repository_storage_path, event.deleted_path)
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
logger.event_info(
event_log.created_at,
message: 'Deleted project',
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)
# 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
it 'schedules a GeoRepositoryDestroyWorker' do
project_id = repository_deleted_event.project_id
project_name = repository_deleted_event.deleted_project_name
full_path = File.join(repository_deleted_event.repository_storage_path,
repository_deleted_event.deleted_path)
project_path = repository_deleted_event.deleted_path
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!
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