Skip to content

Return NotFound when accessing non-existent repository

Sami Hiltunen requested to merge smh-return-not-found-errors into master

The PerRepositoryRouter expects database records to exist for each accessed repository. This is due to two reasons:

  1. With each repository having their own primary, we don't have a virtual storage's primary anymore to fallback on when we don't know where the replicas exist.

  2. With variable replication factor, we really need to know where to send the request as not every storage contains all repositories anymore.

This behavior caused problems for Rails, as Rails sends us requests about repositories which do not exist. This could be due to various race conditions or the repository might still be present in Rails' caches. Rails is catching not found errors returned and handles them gracefully.

Prior to this commit, the PerRepositoryRouter was returning 'no suitable node to serve request' errors when we didn't have a node we could serve the request from. This case was also hit when the repository had no database records. To differentiate the repository existing but all host nodes being unaccessible from Rails asking for a non-existent repository, this commit returns a proper status code to indicate the repository did not exist.

This worked with virtual storage scoped primaries due to the fallback to primary behavior when no replicas where found from the database. The primary would then return NotFound when trying to access a non-existent repository on the disk. This behavior is still maintained and the case when no database records exist is ignored when virtual storage scoped primaries are used.

Related to #3492 (closed)
Closes #3391 (closed)

Merge request reports

Loading