Skip to content

Skip registry import after too many retries

Steve Abrams requested to merge 356401-skip-imports-on-max-retries into master

What does this MR do and why?

We are working on migrating all container repositories to the new container registry. The GitLab rails project is in charge of kicking off the imports and keeping track of their current migration_state.

If for some reason something goes wrong during an import of a container repository, we abort the import and set the migration_state to import_aborted. From there, rails will eventually retry the import. We keep track of how many times we have aborted a given container repository using container_repository.migration_retries_count.

We added an application setting container_registry_import_max_retries to control how many times a container repository can be aborted before we stop trying and skip the import, setting the migration_state to import_skipped.

The problem is we never added any logic to do this 🤦.

This MR updates the ContainerRepository migration_state state machine so after a container repository transitions to import_aborted we check if it has reached the container_registry_import_max_retries limit. If it has, we then skip the import.

The import and migration functionality lives behind a feature flag, so this MR does not contain a changelog.

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. You can create a container repository record locally and set it with a few retries:
FactoryBot.create(:container_repository, project: Project.first, migration_retries_count: 3)
  1. Then update the application setting to also be that number or lower:
ApplicationSetting.update(container_registry_import_max_retries: 3)
  1. Try to abort the container repository import:
ContainerRepository.last.abort_import
  1. Check the migration_state of the container repository, it should be import_skipped:
ContainerRepository.last.migration_state

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 #356401 (closed)

Edited by David Fernandez

Merge request reports

Loading