Resolve "GitLab Migration - Add GitLab version check for Project Migration"
requested to merge 341422-gitlab-migration-add-gitlab-version-check-for-project-migration into master
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
How to set up and validate locally
- 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
Feature.enable(:bulk_import)
Feature.enable(:bulk_import_projects)
- Create a top level group and project in it
- Go to
/groups/new#import-group-pane
page and enter instance url and access token (needs to beapi
scope) - Select newly created group and click Import
- Wait for Group import to complete and verify that only the group has been imported NOT the project
- On the
import/bulk_imports/status
page, open your HTML inspector. - Open the Network tab. Reload the page if there's nothing showing.
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #341422 (closed)
Edited by João Alexandre Cunha