Commit da0ea5c0 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'raise_error_when_repository_move_fails' into 'master'

Raise the error when repository storage move fails

See merge request gitlab-org/gitlab!65292
parents 252da69a 8f5a5473
...@@ -38,11 +38,7 @@ module UpdateRepositoryStorageMethods ...@@ -38,11 +38,7 @@ module UpdateRepositoryStorageMethods
rescue StandardError => e rescue StandardError => e
repository_storage_move.do_fail! repository_storage_move.do_fail!
Gitlab::ErrorTracking.track_exception(e, container_klass: container.class.to_s, container_path: container.full_path) Gitlab::ErrorTracking.track_and_raise_exception(e, container_klass: container.class.to_s, container_path: container.full_path)
ServiceResponse.error(
message: s_("UpdateRepositoryStorage|Error moving repository storage for %{container_full_path} - %{message}") % { container_full_path: container.full_path, message: e.message }
)
end end
private private
......
...@@ -76,9 +76,10 @@ RSpec.describe Groups::UpdateRepositoryStorageService do ...@@ -76,9 +76,10 @@ RSpec.describe Groups::UpdateRepositoryStorageService do
.with(wiki.repository.raw) .with(wiki.repository.raw)
.and_raise(Gitlab::Git::CommandError) .and_raise(Gitlab::Git::CommandError)
result = subject.execute expect do
subject.execute
end.to raise_error(Gitlab::Git::CommandError)
expect(result).to be_error
expect(group.reload).not_to be_repository_read_only expect(group.reload).not_to be_repository_read_only
expect(wiki.repository_storage).to eq('default') expect(wiki.repository_storage).to eq('default')
expect(repository_storage_move).to be_failed expect(repository_storage_move).to be_failed
...@@ -94,9 +95,10 @@ RSpec.describe Groups::UpdateRepositoryStorageService do ...@@ -94,9 +95,10 @@ RSpec.describe Groups::UpdateRepositoryStorageService do
expect(original_wiki_repository_double).to receive(:remove) expect(original_wiki_repository_double).to receive(:remove)
.and_raise(Gitlab::Git::CommandError) .and_raise(Gitlab::Git::CommandError)
result = subject.execute expect do
subject.execute
end.to raise_error(Gitlab::Git::CommandError)
expect(result).to be_error
expect(repository_storage_move).to be_cleanup_failed expect(repository_storage_move).to be_cleanup_failed
end end
end end
...@@ -108,9 +110,10 @@ RSpec.describe Groups::UpdateRepositoryStorageService do ...@@ -108,9 +110,10 @@ RSpec.describe Groups::UpdateRepositoryStorageService do
expect(wiki_repository_double).to receive(:checksum) expect(wiki_repository_double).to receive(:checksum)
.and_return('not matching checksum') .and_return('not matching checksum')
result = subject.execute expect do
subject.execute
end.to raise_error(UpdateRepositoryStorageMethods::Error, /Failed to verify wiki repository checksum from \w+ to not matching checksum/)
expect(result).to be_error
expect(group).not_to be_repository_read_only expect(group).not_to be_repository_read_only
expect(wiki.repository_storage).to eq('default') expect(wiki.repository_storage).to eq('default')
end end
......
...@@ -35016,9 +35016,6 @@ msgstr "" ...@@ -35016,9 +35016,6 @@ msgstr ""
msgid "UpdateProject|Project could not be updated!" msgid "UpdateProject|Project could not be updated!"
msgstr "" msgstr ""
msgid "UpdateRepositoryStorage|Error moving repository storage for %{container_full_path} - %{message}"
msgstr ""
msgid "UpdateRepositoryStorage|Failed to verify %{type} repository checksum from %{old} to %{new}" msgid "UpdateRepositoryStorage|Failed to verify %{type} repository checksum from %{old} to %{new}"
msgstr "" msgstr ""
......
...@@ -83,9 +83,10 @@ RSpec.describe Projects::UpdateRepositoryStorageService do ...@@ -83,9 +83,10 @@ RSpec.describe Projects::UpdateRepositoryStorageService do
.with(project.repository.raw) .with(project.repository.raw)
.and_raise(Gitlab::Git::CommandError) .and_raise(Gitlab::Git::CommandError)
result = subject.execute expect do
subject.execute
end.to raise_error(Gitlab::Git::CommandError)
expect(result).to be_error
expect(project).not_to be_repository_read_only expect(project).not_to be_repository_read_only
expect(project.repository_storage).to eq('default') expect(project.repository_storage).to eq('default')
expect(repository_storage_move).to be_failed expect(repository_storage_move).to be_failed
...@@ -101,9 +102,10 @@ RSpec.describe Projects::UpdateRepositoryStorageService do ...@@ -101,9 +102,10 @@ RSpec.describe Projects::UpdateRepositoryStorageService do
expect(original_project_repository_double).to receive(:remove) expect(original_project_repository_double).to receive(:remove)
.and_raise(Gitlab::Git::CommandError) .and_raise(Gitlab::Git::CommandError)
result = subject.execute expect do
subject.execute
end.to raise_error(Gitlab::Git::CommandError)
expect(result).to be_error
expect(repository_storage_move).to be_cleanup_failed expect(repository_storage_move).to be_cleanup_failed
end end
end end
...@@ -118,9 +120,10 @@ RSpec.describe Projects::UpdateRepositoryStorageService do ...@@ -118,9 +120,10 @@ RSpec.describe Projects::UpdateRepositoryStorageService do
expect(project_repository_double).to receive(:checksum) expect(project_repository_double).to receive(:checksum)
.and_return('not matching checksum') .and_return('not matching checksum')
result = subject.execute expect do
subject.execute
end.to raise_error(UpdateRepositoryStorageMethods::Error, /Failed to verify project repository checksum/)
expect(result).to be_error
expect(project).not_to be_repository_read_only expect(project).not_to be_repository_read_only
expect(project.repository_storage).to eq('default') expect(project.repository_storage).to eq('default')
end end
......
...@@ -75,9 +75,10 @@ RSpec.describe Snippets::UpdateRepositoryStorageService do ...@@ -75,9 +75,10 @@ RSpec.describe Snippets::UpdateRepositoryStorageService do
.with(snippet.repository.raw) .with(snippet.repository.raw)
.and_raise(Gitlab::Git::CommandError) .and_raise(Gitlab::Git::CommandError)
result = subject.execute expect do
subject.execute
end.to raise_error(Gitlab::Git::CommandError)
expect(result).to be_error
expect(snippet).not_to be_repository_read_only expect(snippet).not_to be_repository_read_only
expect(snippet.repository_storage).to eq('default') expect(snippet.repository_storage).to eq('default')
expect(repository_storage_move).to be_failed expect(repository_storage_move).to be_failed
...@@ -93,9 +94,10 @@ RSpec.describe Snippets::UpdateRepositoryStorageService do ...@@ -93,9 +94,10 @@ RSpec.describe Snippets::UpdateRepositoryStorageService do
expect(original_snippet_repository_double).to receive(:remove) expect(original_snippet_repository_double).to receive(:remove)
.and_raise(Gitlab::Git::CommandError) .and_raise(Gitlab::Git::CommandError)
result = subject.execute expect do
subject.execute
end.to raise_error(Gitlab::Git::CommandError)
expect(result).to be_error
expect(repository_storage_move).to be_cleanup_failed expect(repository_storage_move).to be_cleanup_failed
end end
end end
...@@ -107,9 +109,10 @@ RSpec.describe Snippets::UpdateRepositoryStorageService do ...@@ -107,9 +109,10 @@ RSpec.describe Snippets::UpdateRepositoryStorageService do
expect(snippet_repository_double).to receive(:checksum) expect(snippet_repository_double).to receive(:checksum)
.and_return('not matching checksum') .and_return('not matching checksum')
result = subject.execute expect do
subject.execute
end.to raise_error(UpdateRepositoryStorageMethods::Error, /Failed to verify snippet repository checksum from \w+ to not matching checksum/)
expect(result).to be_error
expect(snippet).not_to be_repository_read_only expect(snippet).not_to be_repository_read_only
expect(snippet.repository_storage).to eq('default') expect(snippet.repository_storage).to eq('default')
end end
......
...@@ -123,9 +123,10 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| ...@@ -123,9 +123,10 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
.with(repository.raw) .with(repository.raw)
.and_raise(Gitlab::Git::CommandError) .and_raise(Gitlab::Git::CommandError)
result = subject.execute expect do
subject.execute
end.to raise_error(Gitlab::Git::CommandError)
expect(result).to be_error
expect(project).not_to be_repository_read_only expect(project).not_to be_repository_read_only
expect(project.repository_storage).to eq('default') expect(project.repository_storage).to eq('default')
expect(repository_storage_move).to be_failed expect(repository_storage_move).to be_failed
...@@ -149,9 +150,10 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| ...@@ -149,9 +150,10 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
expect(original_repository_double).to receive(:remove) expect(original_repository_double).to receive(:remove)
.and_raise(Gitlab::Git::CommandError) .and_raise(Gitlab::Git::CommandError)
result = subject.execute expect do
subject.execute
end.to raise_error(Gitlab::Git::CommandError)
expect(result).to be_error
expect(repository_storage_move).to be_cleanup_failed expect(repository_storage_move).to be_cleanup_failed
end end
end end
...@@ -170,9 +172,10 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| ...@@ -170,9 +172,10 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
allow(repository_double).to receive(:checksum) allow(repository_double).to receive(:checksum)
.and_return('not matching checksum') .and_return('not matching checksum')
result = subject.execute expect do
subject.execute
end.to raise_error(UpdateRepositoryStorageMethods::Error, /Failed to verify \w+ repository checksum from \w+ to not matching checksum/)
expect(result).to be_error
expect(project).not_to be_repository_read_only expect(project).not_to be_repository_read_only
expect(project.repository_storage).to eq('default') expect(project.repository_storage).to eq('default')
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