Skip to content

Add a force cancel param to the gitlab registry client

Steve Abrams requested to merge 357939-force-import-cancellation-method into master

🔎 What does this MR do and why?

We are in the process of preparing to migrate all existing container repositories to the new container registry. Rails drives much of the migration by making API requests to the container registry to start imports and cancel imports.

Right now, we have a cancel endpoint that allows us to cancel an ongoing import, however, it will only cancel if certain conditions are true on the registry side. We are adding a param to the registry API to allow us to forcefully cancel the import.

The option is not expected to be used in the normal import workflow, however, we want it as a safety measure in case an admin or SRE needs to cancel an import during the process (the migration is expected to take place over multiple months) from the console.

We add a new method, #force_migration_cancel, on ContainerRepository to use the force param and skip the migration.

The entire migration process is behind a feature flag and we are testing the end to end behavior on staging right now. So this scenario of force cancelling an import will be tested on staging.

📺 Screenshots or screen recordings

N/A

📝 How to set up and validate locally

This cannot be easily set up locally as it involves additional changes currently also being added to the container registry. You can test that the method calls the registry with the new option and that rails handles the returning error:

  1. Ensure the registry is running locally
  2. Cancel a migration on a container repository with the new option. The response should be :error, but no exceptions should be raised.
ContainerRepository.first.force_cancel_migration
=> :error

📐 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: #357939 (closed)

Edited by Steve Abrams

Merge request reports