Group Migration - Import subgroups
What does this MR do?
related to: #270074 (closed)
This is a second try on solving this problem. This solution was build in a pairing session with @georgekoltsov based on !46248 (closed).
This MR adds support to migrate all subgroups of the groups imported using the BulkImport feature.
The SubgroupsPipeline
fetches all the subgroups of the imported group and create new BulkImport::Entity
for each subgroup. This advantages of this approach are:
- fetch one level of a group tree per background job (avoiding too long jobs)
- the
parent_id
,destination_full_path
don't require any calculations - the same ETL abstractions are used
Diagrams
Flow overview:
graph LR
BulkImportService.create[Create BulkImport and <br> BulkImport::Entity records]
subgraph async
BulkImportWorker--> GroupsImporter
GroupsImporter --> bulk_import{has importable <br> entities?}
bulk_import --> |yes| StartBulkImport[bulk_import.start!]
StartBulkImport --> GroupImporter
GroupImporter --> GroupPipeline
GroupPipeline --> |creates new entities <br> for each subgroup| SubgroupsPipeline
SubgroupsPipeline --> |perform_async| BulkImportWorker
bulk_import --> |no| FinishBulkImport[bulk_import.finish!]
end
subgraph sync
User-->BulkImportController
BulkImportController--> BulkImportService
BulkImportService --> BulkImportService.create
BulkImportService.create --> |perform_async| BulkImportWorker
end
The sync sequence
sequenceDiagram
User->>+BulkImportsController: Import Group A
BulkImportsController->>+BulkImportService: execute
BulkImportService->>BulkImportService: Create BulkImport and Entities
BulkImportService->>BulkImportWorker: perform_async(bulk_import.id)
BulkImportsController->>-User: 201 Created
The async sequence
sequenceDiagram
BulkImportWorker->>+GroupsImporter: new(bulk_import_id).execute
alt bulk_import has entities to be imported
GroupsImporter->>bulk_import: start!
loop bulk_import.entities
GroupsImporter->>GroupImporter: new(entity).execute
GroupImporter->>+GroupPipeline: run
GroupImporter->>+SubgroupsPipeline: run
Note right of SubgroupsPipeline: Creates BulkImport::Entity <br> for each subgroup <br> in the source
end
GroupsImporter->>BulkImportWorker: perform_asyc
else bulk_import has no entities to be imported
GroupsImporter->>bulk_import: finish!
end
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Kassio Borges