This instance will be upgraded to Heptapod 0.31.0rc on 2022-05-19 at 11:00 UTC+2 (a few minutes of down time)

Commit 46fecbd0 authored by Gabriel Mazetto's avatar Gabriel Mazetto
Browse files

Add FeatureFlag to disable hashed storage migration when renaming

We usually want a feature flag to be disabled by default and
hide the feature until it's enabled.

This is an unconventional use: when the flag is enabled, it will
"DISABLE" the behavior.
parent 43a685363178
...@@ -2072,13 +2072,19 @@ def auto_cancel_pending_pipelines? ...@@ -2072,13 +2072,19 @@ def auto_cancel_pending_pipelines?
private private
def rename_or_migrate_repository! def rename_or_migrate_repository!
if Gitlab::CurrentSettings.hashed_storage_enabled? && storage_version != LATEST_STORAGE_VERSION if Gitlab::CurrentSettings.hashed_storage_enabled? &&
storage_upgradable? &&
Feature.disabled?(:disable_hashed_storage_upgrade) # kill switch in case we need to disable upgrade behavior
::Projects::HashedStorageMigrationService.new(self, full_path_was).execute ::Projects::HashedStorageMigrationService.new(self, full_path_was).execute
else else
storage.rename_repo storage.rename_repo
end end
end end
def storage_upgradable?
storage_version != LATEST_STORAGE_VERSION
end
def after_rename_repository(full_path_before, path_before) def after_rename_repository(full_path_before, path_before)
execute_rename_repository_hooks!(full_path_before) execute_rename_repository_hooks!(full_path_before)
......
...@@ -249,7 +249,17 @@ ...@@ -249,7 +249,17 @@
expect(project.errors.messages[:base]).to include('There is already a repository with that name on disk') expect(project.errors.messages[:base]).to include('There is already a repository with that name on disk')
end end
context 'when hashed storage enabled' do it 'renames the project without upgrading it' do
result = update_project(project, admin, path: 'new-path')
expect(result).not_to include(status: :error)
expect(project).to be_valid
expect(project.errors).to be_empty
expect(project.disk_path).to include('new-path')
expect(project.reload.hashed_storage?(:repository)).to be_falsey
end
context 'when hashed storage is enabled' do
before do before do
stub_application_setting(hashed_storage_enabled: true) stub_application_setting(hashed_storage_enabled: true)
end end
...@@ -262,6 +272,22 @@ ...@@ -262,6 +272,22 @@
expect(project.errors).to be_empty expect(project.errors).to be_empty
expect(project.reload.hashed_storage?(:repository)).to be_truthy expect(project.reload.hashed_storage?(:repository)).to be_truthy
end end
context 'when disable_hashed_storage_upgrade feature flag is enabled' do
before do
expect(Feature).to receive(:enabled?).with(:disable_hashed_storage_upgrade) { true }
end
it 'renames the project without upgrading it' do
result = update_project(project, admin, path: 'new-path')
expect(result).not_to include(status: :error)
expect(project).to be_valid
expect(project.errors).to be_empty
expect(project.disk_path).to include('new-path')
expect(project.reload.hashed_storage?(:repository)).to be_falsey
end
end
end end
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