Exclude deleted projects from GetProjectsQuery
What does this MR do and why?
When initiating a direct transfer, if a project at the source had recently been deleted, it would try to import that project as well.
This MR excludes deleted projects from the GetProjectsQuery, so they don't get imported.
This only works when source version is >= 16.1. The notAimedForDeletion
parameter is omitted if dealing with an older GitLab version.
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.
Screenshots or screen recordings
How to set up and validate locally
- Enable direct transfers:
ApplicationSetting.first.update!(bulk_import_enabled: true)
- Create a group in staging with 2 projects. Then delete one.
- Immediately after, run the following command (replacing the values in
<>
):
curl --request POST \
--url http://127.0.0.1:3000/api/v4/bulk_imports \
--header 'Content-Type: application/json' \
--header 'PRIVATE-TOKEN: <localhost pat>' \
--data '{
"configuration": {
"url": "https://staging.gitlab.com",
"access_token": "<staging pat>"
},
"entities": [
{
"source_full_path": "<source group path>",
"source_type": "group_entity",
"destination_slug": "exclude-deleted-test",
"destination_namespace": "<destination namespace>"
}
]
}'
- Once the import completes, confirm there are no errors in Sidekiq
- You can also run the following after to ensure your deleted project is not included:
tracker = BulkImports::Tracker.where(relation: "BulkImports::Groups::Pipelines::ProjectEntitiesPipeline").last
context = BulkImports::Pipeline::Context.new(tracker)
extractor = BulkImports::Common::Extractors::GraphqlExtractor.new(query: BulkImports::Groups::Graphql::GetProjectsQuery)
extractor.extract(context)
Related to #460238 (closed)
Edited by Keeyan Nejad