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 bba99da9 authored by Stan Hu's avatar Stan Hu

Improve logging when username update fails due to registry tags

When a user cannot be renamed due to existing container registry tags, log the
namespace and an example project that has tags.
parent 2bb8c1ca
......@@ -5,8 +5,10 @@ module LegacyNamespace
extend ActiveSupport::Concern
def move_dir
if any_project_has_container_registry_tags?
raise Gitlab::UpdatePathError.new('Namespace cannot be moved, because at least one project has tags in container registry')
proj_with_tags = first_project_with_container_registry_tags
if proj_with_tags
raise Gitlab::UpdatePathError.new("Namespace #{name} (#{id}) cannot be moved because at least one project (e.g. #{proj_with_tags.name} (#{proj_with_tags.id})) has tags in container registry")
end
parent_was = if parent_changed? && parent_id_was.present?
......
......@@ -135,6 +135,10 @@ def any_project_has_container_registry_tags?
all_projects.any?(&:has_container_registry_tags?)
end
def first_project_with_container_registry_tags
all_projects.find(&:has_container_registry_tags?)
end
def send_update_instructions
projects.each do |project|
project.send_move_instructions("#{full_path_was}/#{project.path}")
......
---
title: Improve logging when username update fails due to registry tags
merge_request: 22038
author:
type: other
......@@ -82,6 +82,27 @@
it { expect(namespace.human_name).to eq(namespace.owner_name) }
end
describe '#first_project_with_container_registry_tags' do
let(:container_repository) { create(:container_repository) }
let!(:project) { create(:project, namespace: namespace, container_repositories: [container_repository]) }
before do
stub_container_registry_config(enabled: true)
end
it 'returns the project' do
stub_container_registry_tags(repository: :any, tags: ['tag'])
expect(namespace.first_project_with_container_registry_tags).to eq(project)
end
it 'returns no project' do
stub_container_registry_tags(repository: :any, tags: nil)
expect(namespace.first_project_with_container_registry_tags).to be_nil
end
end
describe '.search' do
let(:namespace) { create(:namespace) }
......@@ -184,7 +205,8 @@
end
it 'raises an error about not movable project' do
expect { namespace.move_dir }.to raise_error(/Namespace cannot be moved/)
expect { namespace.move_dir }.to raise_error(Gitlab::UpdatePathError,
/Namespace .* cannot be moved/)
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