Skip to content

Rename a base container repository (and all sub-repositories, if any) (PART 2/3)

Context

With the completion of #894 (closed) (and the investigation on "rename-lease" in #896 (closed) ) we are now in a good position to extend the API dry-run option to be able to obtain a "rename-lease" as suggested in "(2)" of gitlab#381392 (closed).

Full context can be found here

The "rename lease" is expected to be used as follows, (when rename's are supported):

  • When processing the dry-run rename request, the registry would acquire a rename lease for paths that match ^my-group\/(old-name|new-name)($|\/.*$). This lease would have a short TTL of N seconds after which writes against a matching repository would be no longer blocked. If the dry-run succeeds (the rename is technically possible), Rails would be informed in the response that it had N seconds to complete the operation. If the dry-run did not succeed, the lease would be released ahead of time.
  • When receiving the non-dry-run rename request, the registry would ensure the lease is still alive and enough time remains before it expires (e.g., it won't expire before the configured DB transaction timeout of 10 seconds). If so, the rename proceeds, otherwise it's halted and Rails should get back to square one. Leases would be released at the end of a request, regardless of the result.
  • Across the whole registry API, a write request against a given repository (be that a blob upload, a tag delete, etc.) would only be allowed if a rename lease for the target repository does not exist.

Tasks

  • Extend the container registryAPI-GitLab-V1 for the existing PATCH /gitlab/v1/repositories/<path>/ endpoint to grant a "rename-lease"

    Note: In a future iteration we will rollout the rename-lease checks across all registry API handlers #925 (closed)

Edited by SAhmed