Skip to content

Improve the container registry client

🌲 Context

The rails backend has to contact the Container Registry for different operations. One of them is deleting tags.

This operation was quite slow. It was improved with !23325 (merged). This MR introduced an additional API on the GitLab Container Registry that is more efficient to delete tags.

gitlab.com uses the GitLab Container Registry and thus can use the new way to delete tags.

self-managed can use a third party container registry and thus we must use the old way to delete tags.

To know which method needs to be used, #supports_tag_delete was created in the container registry client. This method will simply ping (OPTIONS method) the container registry to know which APIs are available.

This method will ping the container registry no matter what are the conditions.

We can save this ping if we are on gitlab.com and the applications settings for the container registry features has the delete tag feature.

What does this MR do?

  • Early return true in #supports_tag_delete if we are on gitlab.com with the right conditions
  • Refactor the related specs to use table based specs
    • This function is central to several processing and its output depends on different conditions. We really want to exhaustively test all possible conditions combinations (yes, even those that don't make sense) to make sure that the result is the expected one and also that we don't ping the container registry when we don't need to.

Screenshots (strongly suggested)

n / a

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

Related to #227808 (closed)

Edited by David Fernandez

Merge request reports