Commit f469bb8e authored by Stan Hu's avatar Stan Hu

Merge branch '56618-hashed-storage-skip-validation' into 'master'

Resolve "Hashed storage migration should not be attempted if project does not validate"

Closes #56618

See merge request gitlab-org/gitlab-ce!25753
parents a1a8202f b4f20502
...@@ -24,7 +24,7 @@ module Projects ...@@ -24,7 +24,7 @@ module Projects
result = move_folder!(origin, target) result = move_folder!(origin, target)
if result if result
project.save! project.save!(validate: false)
yield if block_given? yield if block_given?
else else
......
...@@ -27,7 +27,7 @@ module Projects ...@@ -27,7 +27,7 @@ module Projects
end end
project.repository_read_only = false project.repository_read_only = false
project.save! project.save!(validate: false)
if result && block_given? if result && block_given?
yield yield
......
...@@ -19,7 +19,7 @@ module Projects ...@@ -19,7 +19,7 @@ module Projects
result = move_folder!(origin, target) result = move_folder!(origin, target)
if result if result
project.save! project.save!(validate: false)
yield if block_given? yield if block_given?
else else
......
...@@ -27,7 +27,7 @@ module Projects ...@@ -27,7 +27,7 @@ module Projects
end end
project.repository_read_only = false project.repository_read_only = false
project.save! project.save!(validate: false)
if result && block_given? if result && block_given?
yield yield
......
---
title: Skip Project validation during Hashed Storage migration or rollback
merge_request: 25753
author:
type: fixed
...@@ -76,6 +76,12 @@ describe Projects::HashedStorage::MigrateAttachmentsService do ...@@ -76,6 +76,12 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
expect { service.execute }.to raise_error(Projects::HashedStorage::AttachmentCannotMoveError) expect { service.execute }.to raise_error(Projects::HashedStorage::AttachmentCannotMoveError)
end end
end end
it 'works even when project validation fails' do
allow(project).to receive(:valid?) { false }
expect { service.execute }.to change { project.hashed_storage?(:attachments) }.to(true)
end
end end
context '#old_disk_path' do context '#old_disk_path' do
......
...@@ -102,6 +102,12 @@ describe Projects::HashedStorage::MigrateRepositoryService do ...@@ -102,6 +102,12 @@ describe Projects::HashedStorage::MigrateRepositoryService do
end end
end end
it 'works even when project validation fails' do
allow(project).to receive(:valid?) { false }
expect { service.execute }.to change { project.hashed_storage?(:repository) }.to(true)
end
def expect_move_repository(from_name, to_name) def expect_move_repository(from_name, to_name)
expect(gitlab_shell).to receive(:mv_repository).with(project.repository_storage, from_name, to_name).and_call_original expect(gitlab_shell).to receive(:mv_repository).with(project.repository_storage, from_name, to_name).and_call_original
end end
......
...@@ -78,6 +78,12 @@ describe Projects::HashedStorage::RollbackAttachmentsService do ...@@ -78,6 +78,12 @@ describe Projects::HashedStorage::RollbackAttachmentsService do
expect { service.execute }.to raise_error(Projects::HashedStorage::AttachmentCannotMoveError) expect { service.execute }.to raise_error(Projects::HashedStorage::AttachmentCannotMoveError)
end end
end end
it 'works even when project validation fails' do
allow(project).to receive(:valid?) { false }
expect { service.execute }.to change { project.hashed_storage?(:attachments) }.to(false)
end
end end
context '#old_disk_path' do context '#old_disk_path' do
......
...@@ -104,6 +104,12 @@ describe Projects::HashedStorage::RollbackRepositoryService, :clean_gitlab_redis ...@@ -104,6 +104,12 @@ describe Projects::HashedStorage::RollbackRepositoryService, :clean_gitlab_redis
end end
end end
it 'works even when project validation fails' do
allow(project).to receive(:valid?) { false }
expect { service.execute }.to change { project.legacy_storage? }.to(true)
end
def expect_move_repository(from_name, to_name) def expect_move_repository(from_name, to_name)
expect(gitlab_shell).to receive(:mv_repository).with(project.repository_storage, from_name, to_name).and_call_original expect(gitlab_shell).to receive(:mv_repository).with(project.repository_storage, from_name, to_name).and_call_original
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