Update importers to skip placeholder references when possible

What does this MR do and why?

With the introduction of the direct reassignment process, placeholder references are no longer needed when this process is supported.

This change updates importers to check whether the direct reassignment process is supported before creating placeholder references. When supported, importers skip creating these placeholder references.

References

#575651 (closed)

Screenshots or screen recordings

Before After

How to set up and validate locally

Direct Transfer

  1. Perform a Direct Transfer migration
    1. If not already enabled, turn on the Direct Transfer in the admin settings under Admin -> Settings -> General -> Import and export settings -> Import sources -> Allow migrating GitLab groups and projects by direct transfer.
    2. Visit /admin/application_settings/network and enable local requests.
    3. Visit /groups/new#import-group-pane
    4. In GitLab source instance base URL provide your GDK URL, e.g. http://gdk.test:3000
    5. In Personal access token provide your GDK personal access token
    6. Click on Connect Instance
    7. Import a group into another top-level group
  2. Verify in the database that the placeholder references was not created
  3. Apply the patch (see below) to force the Import User to be used.
  4. Import the group again into another top-level group. Do not use the previous top-level group; otherwise, the previously created placeholder users will be used.
  5. Verify that placeholder references were created

GitHub Importer

  1. Create a project on GitHub.com with some contributions (MR, issues, comments)
  2. In GitLab:
    1. If not already enabled, turn on the GitHub Importer in the admin settings under Admin -> Settings -> General -> Import and export settings -> Import sources -> GitHub.
    2. Visit /projects/new#import_project
    3. Choose GitHub.
    4. Provide a GitHub access token
    5. Select a project to be imported
    6. Import the project into a group
    7. Verify in the database that the placeholder references was not created
    8. Apply the patch (see below) to force the Import User to be used.
    9. Creata a new group
    10. Import the project again into the new group
    11. Verify that placeholder references were created

Gitea Importer

  1. Create a project on Gitea.com with some contributions (MR, issues, comments)
  2. In GitLab:
    1. If not already enabled, turn on the Gitea Importer in the admin settings under Admin -> Settings -> General -> Import and export settings -> Import sources -> Gitea.
    2. Visit /projects/new#import_project
    3. Choose Gitea.
    4. Gitea host URL (https://gitea.com)
    5. Provide a Gitea access token
    6. Select a project to be imported
    7. Import the project into a group
    8. Verify in the database that the placeholder references was not created
    9. Apply the patch (see below) to force the Import User to be used.
    10. Create a new group
    11. Import the project again into the new group
    12. Verify that placeholder references were created

Bitbucket Server Importer

  1. Follow the Import and Integration guide to set up a local Bitbucket Server instance.
  2. In the Bitbucket Server instance, create a repo and a PR with comments.
  3. In GitLab:
    1. If not already enabled, turn on the Bitbucket Server Importer in the admin settings under Admin -> Settings -> General -> Import and export settings -> Import sources -> Bitbucket Server.
    2. Visit /admin/application_settings/network and enable local requests.
    3. Visit /projects/new#import_project.
    4. Choose Bitbucket Server.
    5. Enter your server details, and click List your Bitbucket Server repositories.
    6. Import the project into a group
    7. Verify in the database that the placeholder references was not created
    8. Apply the patch (see below) to force the Import User to be used.
    9. Create a new group
    10. Import the project again into the new group
    11. Verify that placeholder references were created

Patch to force Import User to be used

diff --git a/lib/gitlab/import/source_user_mapper.rb b/lib/gitlab/import/source_user_mapper.rb
index 2383a90ad9dc..90fec1e8a9d5 100644
--- a/lib/gitlab/import/source_user_mapper.rb
+++ b/lib/gitlab/import/source_user_mapper.rb
@@ -130,7 +130,7 @@ def namespace_import_user
       end
 
       def placeholder_user_limit_exceeded?
-        ::Import::PlaceholderUserLimit.new(namespace: namespace).exceeded?
+        true
       end
 
       def reset_source_user?(source_user)

MR acceptance checklist

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

Edited by Rodrigo Tomonari

Merge request reports

Loading