GitLab wurde erfolgreich aktualisiert. Dank regelmäßiger Updates bleibt das THM GitLab sicher und Sie profitieren von den neuesten Funktionen. Danke für Ihre Geduld.

Commit b4f20502 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Skip project validation when switching storage layouts

This is a fix for the Hashed Storage migration and Rollback procedure
to ignore any project-level validation error that can happen in a
long-running instance.

There are many situations where defaults and acceptable values changed
but, because we didn't provide a migration to "valid" attributes, it
can happen that project will not be `valid? => true`.

Because the changes we are making are limited to setting a project as
read_only or changing the storage_level, it's safe to bypass validation.
parent 7b4130d0
......@@ -24,7 +24,7 @@ def execute
result = move_folder!(origin, target)
if result
project.save!
project.save!(validate: false)
yield if block_given?
else
......
......@@ -27,7 +27,7 @@ def execute
end
project.repository_read_only = false
project.save!
project.save!(validate: false)
if result && block_given?
yield
......
......@@ -19,7 +19,7 @@ def execute
result = move_folder!(origin, target)
if result
project.save!
project.save!(validate: false)
yield if block_given?
else
......
......@@ -27,7 +27,7 @@ def execute
end
project.repository_read_only = false
project.save!
project.save!(validate: false)
if result && block_given?
yield
......
---
title: Skip Project validation during Hashed Storage migration or rollback
merge_request: 25753
author:
type: fixed
......@@ -76,6 +76,12 @@
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
......
......@@ -102,6 +102,12 @@
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
......
......@@ -78,6 +78,12 @@
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
......
......@@ -104,6 +104,12 @@
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
......
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