Skip to content

Group Migration - Import subgroups

Kassio Borges requested to merge george+kassio/bulkimport-subroup into master

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

Availability and Testing

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

Merge request reports

Loading