Skip to content

Fix race condition on container repository creation

Steve Abrams requested to merge 215715-registry-repository-create-fix into master

What does this MR do?

There are some cases where a race condition can occur when a container repository is created during an image push.

There is a uniqueness constraint on the container repository project_id, name. There is also rails validation on the same attributes. If a race condition occurs and the same repository is created twice using ContainerRepository.create_from_path!, the second will fail with an ActiveRecord::RecordInvalid or ActiveRecord::RecordNotUnique error.

This MR adds a rescue block to ContainerRepository.create_from_path! to check if the container repository already exists if one of these errors is thrown. If it exists, it is returned.

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Related to #215715 (closed)

Edited by Steve Abrams

Merge request reports