Allow transfer of project with registry tags
What does this MR do and why?
In this MR, we start to allow the transfer of projects with registry tags given the following conditions:
- Feature flag
transfer_project_with_tags
is enabled - The GitLab API is supported (i.e. metadata database is enabled in the registry)
- The transfer is within the same top level namespace
Before the actual transfer, we also do a dry run of the command in the container registry API, and only if it succeeds will the transfer proceed, otherwise an error will be raised.
We use ContainerRegistry::GitlabApiClient.move_repository_to_namespace
which was the recently added in #475000 (closed).
MR acceptance checklist
How to set up and validate locally
Prerequisites:
- The metadata database is enabled
- Redis is running (
redis-server --port 6380
) - Groups and subgroups. In the sample below, we would move
ProjectOne
fromSubgroup A
toSubgroup B
which would be allowed. We will also try to moveProjectOne
toGroup2
which would result to an error sinceGroup2
is not in the same top-level namespace. Make sure thatProjectOne
has container images and tags so we can test this update💪
- Group 1
- Subgroup A
- ProjectOne
- Subgroup B
- Subgroup A
- Group 2
A. When the feature flag is disabled
- Verify that the feature flag is disabled
Feature.disabled?(:transfer_project_with_tags)
# => true
# if the feature is enabled, you can disable it with:
Feature.disable(:transfer_project_with_tags)
- Transfer the project to another group within the same top level namespace in Settings > General > Advanced > Transfer project
- You should get an error that the operation is not allowed due to tags.
Project cannot be transferred, because tags are present in its container registry
B. When the feature flag is enabled and transfer in the same top level namespace
- Verify that the feature flag is enabled
Feature.enabled?(:transfer_project_with_tags)
# => true
# if the feature is disabled, you can enable it with:
Feature.enable(:transfer_project_with_tags)
-
Transfer the project to another group within the same top level namespace in Settings > General > Advanced > Transfer project
-
It should be successful
✅ After the transfer, check the Container Registry page for the project and check that the container images and tags are still visible.
C. When the feature flag is enabled and transfer NOT IN the same top level namespace
- Verify that the feature flag is enabled
Feature.enabled?(:transfer_project_with_tags)
# => true
# if the feature is disabled, you can enable it with:
Feature.enable(:transfer_project_with_tags)
-
Transfer the project to another group that is not within the same top level namespace in Settings > General > Advanced > Transfer project
-
There should be an error that it is not allowed to transfer projects with registry tags to a different top level namespace.
Related to #499163