summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/services/projects/hashed_storage/migrate_attachments_service.rb2
-rw-r--r--app/services/projects/hashed_storage/migrate_repository_service.rb2
-rw-r--r--app/services/projects/hashed_storage/rollback_attachments_service.rb2
-rw-r--r--app/services/projects/hashed_storage/rollback_repository_service.rb2
-rw-r--r--changelogs/unreleased/56618-hashed-storage-skip-validation.yml5
-rw-r--r--spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb6
-rw-r--r--spec/services/projects/hashed_storage/migrate_repository_service_spec.rb6
-rw-r--r--spec/services/projects/hashed_storage/rollback_attachments_service_spec.rb6
-rw-r--r--spec/services/projects/hashed_storage/rollback_repository_service_spec.rb6
9 files changed, 33 insertions, 4 deletions
diff --git a/app/services/projects/hashed_storage/migrate_attachments_service.rb b/app/services/projects/hashed_storage/migrate_attachments_service.rb
index 9eaeb6eb4e7..3d0b8f58612 100644
--- a/app/services/projects/hashed_storage/migrate_attachments_service.rb
+++ b/app/services/projects/hashed_storage/migrate_attachments_service.rb
@@ -24,7 +24,7 @@ module Projects
result = move_folder!(origin, target)
if result
- project.save!
+ project.save!(validate: false)
yield if block_given?
else
diff --git a/app/services/projects/hashed_storage/migrate_repository_service.rb b/app/services/projects/hashed_storage/migrate_repository_service.rb
index 5afa8732c0a..e8393128d58 100644
--- a/app/services/projects/hashed_storage/migrate_repository_service.rb
+++ b/app/services/projects/hashed_storage/migrate_repository_service.rb
@@ -27,7 +27,7 @@ module Projects
end
project.repository_read_only = false
- project.save!
+ project.save!(validate: false)
if result && block_given?
yield
diff --git a/app/services/projects/hashed_storage/rollback_attachments_service.rb b/app/services/projects/hashed_storage/rollback_attachments_service.rb
index 6c370ac47e9..5c6b92f965c 100644
--- a/app/services/projects/hashed_storage/rollback_attachments_service.rb
+++ b/app/services/projects/hashed_storage/rollback_attachments_service.rb
@@ -19,7 +19,7 @@ module Projects
result = move_folder!(origin, target)
if result
- project.save!
+ project.save!(validate: false)
yield if block_given?
else
diff --git a/app/services/projects/hashed_storage/rollback_repository_service.rb b/app/services/projects/hashed_storage/rollback_repository_service.rb
index b5c971c70a5..67733f4770b 100644
--- a/app/services/projects/hashed_storage/rollback_repository_service.rb
+++ b/app/services/projects/hashed_storage/rollback_repository_service.rb
@@ -27,7 +27,7 @@ module Projects
end
project.repository_read_only = false
- project.save!
+ project.save!(validate: false)
if result && block_given?
yield
diff --git a/changelogs/unreleased/56618-hashed-storage-skip-validation.yml b/changelogs/unreleased/56618-hashed-storage-skip-validation.yml
new file mode 100644
index 00000000000..c6b32d0bfec
--- /dev/null
+++ b/changelogs/unreleased/56618-hashed-storage-skip-validation.yml
@@ -0,0 +1,5 @@
+---
+title: Skip Project validation during Hashed Storage migration or rollback
+merge_request: 25753
+author:
+type: fixed
diff --git a/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb b/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
index 639dd930618..efe15139717 100644
--- a/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
+++ b/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
@@ -76,6 +76,12 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
expect { service.execute }.to raise_error(Projects::HashedStorage::AttachmentCannotMoveError)
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
context '#old_disk_path' do
diff --git a/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb b/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb
index e77e2198439..42b0d256cbf 100644
--- a/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb
+++ b/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb
@@ -102,6 +102,12 @@ describe Projects::HashedStorage::MigrateRepositoryService do
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)
expect(gitlab_shell).to receive(:mv_repository).with(project.repository_storage, from_name, to_name).and_call_original
end
diff --git a/spec/services/projects/hashed_storage/rollback_attachments_service_spec.rb b/spec/services/projects/hashed_storage/rollback_attachments_service_spec.rb
index 6f4154d6011..815c85e0866 100644
--- a/spec/services/projects/hashed_storage/rollback_attachments_service_spec.rb
+++ b/spec/services/projects/hashed_storage/rollback_attachments_service_spec.rb
@@ -78,6 +78,12 @@ describe Projects::HashedStorage::RollbackAttachmentsService do
expect { service.execute }.to raise_error(Projects::HashedStorage::AttachmentCannotMoveError)
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
context '#old_disk_path' do
diff --git a/spec/services/projects/hashed_storage/rollback_repository_service_spec.rb b/spec/services/projects/hashed_storage/rollback_repository_service_spec.rb
index 41927934501..bd4354a7df3 100644
--- a/spec/services/projects/hashed_storage/rollback_repository_service_spec.rb
+++ b/spec/services/projects/hashed_storage/rollback_repository_service_spec.rb
@@ -104,6 +104,12 @@ describe Projects::HashedStorage::RollbackRepositoryService, :clean_gitlab_redis
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)
expect(gitlab_shell).to receive(:mv_repository).with(project.repository_storage, from_name, to_name).and_call_original
end