Allow to force an import cancelation from the Rails console

Context

We are currently undergoing the container registry migration phase 2 testing on staging.

We currently have the ability to cancel an ongoing (pre)import on the registry side as long as the ongoing (pre) import is in the [pre_import_in_progress or import_in_progress state (container-registry@6edc99b3) in the container registry's database.

However, we cannot cancel an import that has been completed yet. feat: force final import cancelation (container-registry#631 - closed) will allow us to send a DELETE /import/<path>/force=true request to the registry to manually force the cancelation. Once this is done, we should add the ability to manually cancel a completed import from the Rails console, but is not part of the workers driving the migration.

Proposal

Add a new method to the ContainerRepository model force_import_cancelation that will allow an admin to call the DELETE endpoint with the /?force=true flag.

The method should not be part of the state machine and should ideally only be able to be called by an admin or someone who has write access to the console.

Important notes

  • Forcing a cancellation of a completed (pre) import does not send a notification to Rails.
  • Rails should probably verify the status in the registry by calling the GET /import/<path> endpoint and expect a import_failed migration status after forcefully canceling an import
  • import_failed repos will be served via the old path
Edited by Jaime Martinez