Commit e6208143 authored by James Fargher's avatar James Fargher

Remove unneeded RepositoryAlreadyMoved exception

ReplicateRepository already handles this case
parent 36e0dc04
...@@ -5,19 +5,12 @@ module Projects ...@@ -5,19 +5,12 @@ module Projects
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
Error = Class.new(StandardError) Error = Class.new(StandardError)
RepositoryAlreadyMoved = Class.new(StandardError)
def initialize(project) def initialize(project)
@project = project @project = project
end end
def execute(new_repository_storage_key) def execute(new_repository_storage_key)
# Raising an exception is a little heavy handed but this behavior (doing
# nothing if the repo is already on the right storage) prevents data
# loss, so it is valuable for us to be able to observe it via the
# exception.
raise RepositoryAlreadyMoved if project.repository_storage == new_repository_storage_key
mirror_repositories(new_repository_storage_key) mirror_repositories(new_repository_storage_key)
mark_old_paths_for_archive mark_old_paths_for_archive
......
...@@ -9,7 +9,5 @@ class ProjectUpdateRepositoryStorageWorker # rubocop:disable Scalability/Idempot ...@@ -9,7 +9,5 @@ class ProjectUpdateRepositoryStorageWorker # rubocop:disable Scalability/Idempot
project = Project.find(project_id) project = Project.find(project_id)
::Projects::UpdateRepositoryStorageService.new(project).execute(new_repository_storage_key) ::Projects::UpdateRepositoryStorageService.new(project).execute(new_repository_storage_key)
rescue ::Projects::UpdateRepositoryStorageService::RepositoryAlreadyMoved
Rails.logger.info "#{self.class}: repository already moved: #{project}" # rubocop:disable Gitlab/RailsLogger
end end
end end
...@@ -51,7 +51,7 @@ describe Projects::UpdateRepositoryStorageService do ...@@ -51,7 +51,7 @@ describe Projects::UpdateRepositoryStorageService do
it 'bails out and does nothing' do it 'bails out and does nothing' do
expect do expect do
subject.execute(project.repository_storage) subject.execute(project.repository_storage)
end.to raise_error(described_class::RepositoryAlreadyMoved) end.to raise_error(ArgumentError, /repository and source have the same storage/)
end end
end end
......
...@@ -85,7 +85,7 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| ...@@ -85,7 +85,7 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
it 'bails out and does nothing' do it 'bails out and does nothing' do
expect do expect do
subject.execute(project.repository_storage) subject.execute(project.repository_storage)
end.to raise_error(described_class::RepositoryAlreadyMoved) end.to raise_error(ArgumentError, /repository and source have the same storage/)
end end
end end
......
...@@ -14,11 +14,5 @@ describe ProjectUpdateRepositoryStorageWorker do ...@@ -14,11 +14,5 @@ describe ProjectUpdateRepositoryStorageWorker do
subject.perform(project.id, 'new_storage') subject.perform(project.id, 'new_storage')
end end
it 'catches and logs RepositoryAlreadyMoved' do
expect(Rails.logger).to receive(:info).with(/repository already moved/)
expect { subject.perform(project.id, project.repository_storage) }.not_to raise_error
end
end end
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