Skip to content

Enable Project Import to import from remote object storage [RUN ALL RSPEC] [RUN AS-IF-FOSS]

Kassio Borges requested to merge kassio/import-from-external-object-storage into master

What does this MR do?

Currently, the Infrastructure SRE team is frequently asked by Customer Support to run manual exports or imports because they fail due to an enforced size-limit on GitLab.com on http transfers via web and API. To avoid that, this MR adds a new endpoint to import a project from a remote object storage, this way we won't to go through the upload limits.

Current Approach
sequenceDiagram

    User->>+Workhorse: POST /project/import (project.tar.gz)
    note over User, Workhorse: Because the file needs to be uploaded, <br>The file size is limitted by the <br> uploads limits in the ".com"
    Workhorse->>+ObjectStorage: Download project.tar.gz
    ObjectStorage->>-Workhorse: OK
    Workhorse->>+Rails: POST /project/import
    Rails-->>-User: OK
    
    ImporterWorker->>+ObjectStorage: Fetch
    activate ImporterWorker
    ObjectStorage-->>-ImporterWorker: project.tar.gz
    ImporterWorker-->>ImporterWorker: process file
    deactivate ImporterWorker

New approach

sequenceDiagram

    User->>+Rails: POST /project/remote-import (URL for project.tar.gz)
    Rails-->>-User: OK
    note over User,Rails: Instead of passing the file, the user will now pass the URL for the file.<br>This will be saved in the import_export_upload table<br>to be used later in the ImporterWorker to download the file <br>and  process the import.
    
    ImporterWorker->>+RemoteObjectStorage: Fetch
    activate ImporterWorker
    RemoteObjectStorage-->>-ImporterWorker: project.tar.gz
    ImporterWorker-->>ImporterWorker: process file
    deactivate ImporterWorker

Related to: #282503 (closed)

Database migrations

rails db:migrate:up VERSION=20210419203017
$ rails db:migrate:up VERSION=20210419203017
== 20210419203017 AddRemoteImportUrlToImportExportUpload: migrating ===========
-- add_column(:import_export_uploads, :remote_import_url, :text)
   -> 0.0021s
== 20210419203017 AddRemoteImportUrlToImportExportUpload: migrated (0.0021s) ==
rails db:migrate:down VERSION=20210419203017
$ rails db:migrate:down VERSION=20210419203017
== 20210419203017 AddRemoteImportUrlToImportExportUpload: reverting ===========
-- remove_column(:import_export_uploads, :remote_import_url)
   -> 0.0082s
== 20210419203017 AddRemoteImportUrlToImportExportUpload: reverted (0.0083s) ==
rails db:migrate:up VERSION=20210419203018
$ rails db:migrate:up VERSION=20210419203018
== 20210419203018 AddRemoteTextLimitToImportUrlInImportExportUpload: migrating
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0002s
-- execute("ALTER TABLE import_export_uploads\nADD CONSTRAINT check_58f0d37481\nCHECK ( char_length(remote_import_url) <= 512 )\nNOT VALID;\n")
   -> 0.0040s
-- current_schema()
   -> 0.0002s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- execute("ALTER TABLE import_export_uploads VALIDATE CONSTRAINT check_58f0d37481;")
   -> 0.0012s
-- execute("RESET ALL")
   -> 0.0005s
== 20210419203018 AddRemoteTextLimitToImportUrlInImportExportUpload: migrated (0.0162s)
rails db:migrate:down VERSION=20210419203018
$ rails db:migrate:down VERSION=20210419203018
== 20210419203018 AddRemoteTextLimitToImportUrlInImportExportUpload: reverting
-- execute("ALTER TABLE import_export_uploads\nDROP CONSTRAINT IF EXISTS check_58f0d37481\n")
   -> 0.0011s
== 20210419203018 AddRemoteTextLimitToImportUrlInImportExportUpload: reverted (0.0086s)

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 Alex Kalderimis

Merge request reports