Skip to content

Resolve "GitLab Migration - Add GitLab version check for Project Migration"

What does this MR do and why?

  • Renames a constant to be a tad smaller: MIN_MAJOR_VERSION
  • Defines a constant with the MIN_MINOR_VERSION_FOR_PROJECT
  • Starts tracking source GitLab versions for import attempts on the database (BulkImport#source_version (text))
  • Checks if the source GitLab instance has the minimum expected version to support Project Migration. If it hasn't then we don't trigger the project pipeline.
  • Also, sends the source_version to the frontend which will conditionally display a message explaining that if the version is not enough, even if the Project Migration FF is enabled, then projects will to be migrated.

Database Review

Expand

UP

λ  bundle exec rake db:migrate RAILS_ENV=development
== 20211001001222 AddSourceVersionToBulkImports: migrating ====================
-- add_column(:bulk_imports, :source_version, :text)
   -> 0.0043s
== 20211001001222 AddSourceVersionToBulkImports: migrated (0.0043s) ===========

== 20211012091822 AddTextLimitToBulkImportsSourceVersion: migrating ===========
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0005s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE bulk_imports\nADD CONSTRAINT check_ea4e58775a\nCHECK ( char_length(source_version) <= 63 )\nNOT VALID;\n")
   -> 0.0046s
-- current_schema()
   -> 0.0002s
-- execute("SET statement_timeout TO 0")
   -> 0.0008s
-- execute("ALTER TABLE bulk_imports VALIDATE CONSTRAINT check_ea4e58775a;")
   -> 0.0021s
-- execute("RESET statement_timeout")
   -> 0.0008s
== 20211012091822 AddTextLimitToBulkImportsSourceVersion: migrated (0.0449s) ==

Down

λ  be rake db:migrate:down VERSION=20211012091822
== 20211012091822 AddTextLimitToBulkImportsSourceVersion: reverting ===========
-- transaction_open?()
   -> 0.0000s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE bulk_imports\nDROP CONSTRAINT IF EXISTS check_ea4e58775a\n")
   -> 0.0014s
== 20211012091822 AddTextLimitToBulkImportsSourceVersion: reverted (0.0344s) ==
λ  be rake db:migrate:down VERSION=20211001001222
== 20211001001222 AddSourceVersionToBulkImports: reverting ====================
-- remove_column(:bulk_imports, :source_version, :text)
   -> 0.0028s
== 20211001001222 AddSourceVersionToBulkImports: reverted (0.0074s) ===========

Screenshots or screen recordings

Example Group with 2 projects

Screen_Shot_2021-10-06_at_6.40.47_PM

When gitlab version is not enough

FE is notified

Screen_Shot_2021-10-06_at_6.38.38_PM

group is migrated, project is not migrated

imported_group_wo_projects

imported_group_wo_project_group_page

When gitlab version is enough

FE is notified

fe

group and project are migrated

imported_group_with_projects

imported_group_with_project_group_page

How to set up and validate locally

  1. Change the code to expect a higher GitLab version for project migration. For instance, change:
    # app/models/bulk_import.rb
    
    - MIN_MINOR_VERSION_FOR_PROJECT = 4 
    + MIN_MINOR_VERSION_FOR_PROJECT = 8
  2. Feature.enable(:bulk_import)
  3. Feature.enable(:bulk_import_projects)
  4. Create a top level group and project in it
  5. Go to /groups/new#import-group-pane page and enter instance url and access token (needs to be api scope)
  6. Select newly created group and click Import
  7. Wait for Group import to complete and verify that only the group has been imported NOT the project
  8. On the import/bulk_imports/status page, open your HTML inspector.
  9. Open the Network tab. Reload the page if there's nothing showing.
  10. Filter by the status.json request and verify the it contains the correct json response:
    {
    importable_data: ... ,
    version_validation: {
      features: {
        project_migration: {
          available: false
          min_version: "14.8.0"
        },
        source_instance_version: "14.4.0"

-->

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #341422 (closed)

Edited by João Alexandre Cunha

Merge request reports