Skip to content

Allow transfer of project with registry tags

Adie (she/her) requested to merge 499163-allow-transferring-proj-with-tags into master

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:

  1. Feature flag transfer_project_with_tags is enabled
  2. The GitLab API is supported (i.e. metadata database is enabled in the registry)
  3. 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

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Prerequisites:

  1. The metadata database is enabled
  2. Redis is running (redis-server --port 6380)
  3. Groups and subgroups. In the sample below, we would move ProjectOne from Subgroup A to Subgroup B which would be allowed. We will also try to move ProjectOne to Group2 which would result to an error since Group2 is not in the same top-level namespace. Make sure that ProjectOne has container images and tags so we can test this update 💪
  • Group 1
    • Subgroup A
      • ProjectOne
    • Subgroup B
  • Group 2

A. When the feature flag is disabled

  1. 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)
  1. Transfer the project to another group within the same top level namespace in Settings > General > Advanced > Transfer project

Screenshot_2024-11-01_at_21.01.39

  1. 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

  1. 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)
  1. Transfer the project to another group within the same top level namespace in Settings > General > Advanced > Transfer project

  2. 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.

Screenshot: Container Registry page Screenshot_2024-11-01_at_21.06.43

C. When the feature flag is enabled and transfer NOT IN the same top level namespace

  1. 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)
  1. Transfer the project to another group that is not within the same top level namespace in Settings > General > Advanced > Transfer project

  2. There should be an error that it is not allowed to transfer projects with registry tags to a different top level namespace.

Screenshot_2024-11-01_at_14.24.38

Related to #499163

Edited by Adie (she/her)

Merge request reports

Loading