Add partial tags delete support to the API for bulk removal of tags at the project level

Summary

Currently, when using the API for bulk removal of tags at the project level, there is a limitation in the implementation: tags are deleted only if other tags pointing to the same digest are also selected for destruction.

Example:

  • A container repository with tags foo and bar pointing to the same digest.
  • Calling DELETE /projects/:id/registry/repositories/:repository_id/tags?name_regex=foo will not do anything.

The proper expectation would be:

  • foo is deleted but not bar.

Improvements

A safe way to implement tags have been implemented, see !16886 (merged).

We can update the API side to use this new implementation and thus, properly delete tags even if they share a common digest with tags that are not selected for destruction.

Risks

  • Delete tags that are not in the selection filters.

Involved components

  • Projects::ContainerRepository::CleanupTagsService should use Projects::ContainerRepository::DeleteTagsService instead of calling ContainerRegistry::Tag#unsafe_delete.
  • Investigate if it would be worth to merge Projects::ContainerRepository::CleanupTagsService and Projects::ContainerRepository::DeleteTagsService into a single service accepting several way to select tags (by array of names and/or by filters)
Edited by David Fernandez