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
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
Direct Transfer
- Perform a Direct Transfer migration
- 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.
- Visit
/admin/application_settings/networkand enable local requests. - Visit
/groups/new#import-group-pane - In GitLab source instance base URL provide your GDK URL, e.g.
http://gdk.test:3000 - In Personal access token provide your GDK personal access token
- Click on
Connect Instance - Import a group into another top-level group
- Verify in the database that the placeholder references was not created
- Apply the patch (see below) to force the Import User to be used.
- 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.
- Verify that placeholder references were created
GitHub Importer
- Create a project on GitHub.com with some contributions (MR, issues, comments)
- In GitLab:
- If not already enabled, turn on the GitHub Importer in the admin settings under Admin -> Settings -> General -> Import and export settings -> Import sources -> GitHub.
- Visit
/projects/new#import_project - Choose GitHub.
- Provide a GitHub access token
- Select a project to be imported
- Import the project into a group
- Verify in the database that the placeholder references was not created
- Apply the patch (see below) to force the Import User to be used.
- Creata a new group
- Import the project again into the new group
- Verify that placeholder references were created
Gitea Importer
- Create a project on Gitea.com with some contributions (MR, issues, comments)
- In GitLab:
- If not already enabled, turn on the Gitea Importer in the admin settings under Admin -> Settings -> General -> Import and export settings -> Import sources -> Gitea.
- Visit
/projects/new#import_project - Choose Gitea.
- Gitea host URL (https://gitea.com)
- Provide a Gitea access token
- Select a project to be imported
- Import the project into a group
- Verify in the database that the placeholder references was not created
- Apply the patch (see below) to force the Import User to be used.
- Create a new group
- Import the project again into the new group
- Verify that placeholder references were created
Bitbucket Server Importer
- Follow the Import and Integration guide to set up a local Bitbucket Server instance.
- In the Bitbucket Server instance, create a repo and a PR with comments.
- In GitLab:
- 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.
- Visit
/admin/application_settings/networkand enable local requests. - Visit
/projects/new#import_project. - Choose Bitbucket Server.
- Enter your server details, and click List your Bitbucket Server repositories.
- Import the project into a group
- Verify in the database that the placeholder references was not created
- Apply the patch (see below) to force the Import User to be used.
- Create a new group
- Import the project again into the new group
- 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