Commit 1f59edd2 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'fix_shard_move_archive' into 'master'

Ensure original repository is archived after a shard move

Closes #223128

See merge request gitlab-org/gitlab!34895
parents 550c4c51 23dd285a
...@@ -93,25 +93,25 @@ module Projects ...@@ -93,25 +93,25 @@ module Projects
old_repository_storage = project.repository_storage old_repository_storage = project.repository_storage
new_project_path = moved_path(project.disk_path) new_project_path = moved_path(project.disk_path)
# Notice that the block passed to `run_after_commit` will run with `project` # Notice that the block passed to `run_after_commit` will run with `repository_storage_move`
# as its context # as its context
project.run_after_commit do repository_storage_move.run_after_commit do
GitlabShellWorker.perform_async(:mv_repository, GitlabShellWorker.perform_async(:mv_repository,
old_repository_storage, old_repository_storage,
disk_path, project.disk_path,
new_project_path) new_project_path)
if wiki.repository_exists? if project.wiki.repository_exists?
GitlabShellWorker.perform_async(:mv_repository, GitlabShellWorker.perform_async(:mv_repository,
old_repository_storage, old_repository_storage,
wiki.disk_path, project.wiki.disk_path,
"#{new_project_path}.wiki") "#{new_project_path}.wiki")
end end
if design_repository.exists? if project.design_repository.exists?
GitlabShellWorker.perform_async(:mv_repository, GitlabShellWorker.perform_async(:mv_repository,
old_repository_storage, old_repository_storage,
design_repository.disk_path, project.design_repository.disk_path,
"#{new_project_path}.design") "#{new_project_path}.design")
end end
end end
......
---
title: Ensure original repository is archived after a shard move
merge_request: 34895
author:
type: fixed
...@@ -43,6 +43,8 @@ describe Projects::UpdateRepositoryStorageService do ...@@ -43,6 +43,8 @@ describe Projects::UpdateRepositoryStorageService do
.with(project.repository.raw) .with(project.repository.raw)
expect(project_repository_double).to receive(:checksum) expect(project_repository_double).to receive(:checksum)
.and_return(checksum) .and_return(checksum)
expect(GitlabShellWorker).to receive(:perform_async).with(:mv_repository, 'default', anything, anything)
.and_call_original
result = subject.execute result = subject.execute
......
...@@ -38,6 +38,9 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type| ...@@ -38,6 +38,9 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
.with(repository.raw) .with(repository.raw)
allow(repository_double).to receive(:checksum) allow(repository_double).to receive(:checksum)
.and_return(repository_checksum) .and_return(repository_checksum)
expect(GitlabShellWorker).to receive(:perform_async).with(:mv_repository, 'default', anything, anything)
.twice.and_call_original
end end
it "moves the project and its #{repository_type} repository to the new storage and unmarks the repository as read only" do it "moves the project and its #{repository_type} repository to the new storage and unmarks the repository as read only" do
......
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