Skip to content

chore(datastore): introduce rename repository

Suleimi Ahmed requested to merge 895-repository-leases into master

Related to #895 (closed)

Context 💬

This MR introduces the concept of repository-leases as discussed in Investigate: Container registry "Rename Lease" (#896 - closed)

Summary 🍰

A repository-lease is a synchronization abstraction that grants the repository that references it exclusive access to the leased entity. For this particular case the repository lease is used to grant to an existing repository, exclusive rights of a new repository name (i.e a repository name that is not yet in use in the registry).

Why?

This prevents race conditions when different repositories might be trying to be renamed to the same name. In a future iteration we plan to stop all CRUD operations on a repository if a lease exists under its name, hence preventing data inconsistencies

How?

We implement the leasing logic by Seting and Geting the lease object from redis. The lease object is subject to a default TTL of 60sec once requested following the flow highlighted here. Once a repository rename lease has been obtained the process can then begin the rename operation on the database, committing the rename only if the transaction is successful.

General Notes?

  • The synchronization backend for the repository lease is the redis cache, and because of this it is a necessary dependency to perform any sort of rename operation #896 (comment 1279879708)

Merge request reports