Fix 'error resolving descriptor in ServeBlob listener: unknown blob' when filesystem mirroring is disabled
Context
This error was observed in the pre environment with filesystem mirroring disabled. When blobs were being retrieved on repositories without filesystem mirroring. This is a logging error only, but it should still be avoided, and it prevents the listener from emitting blobPulled
events.
Problem
This error is emitted at the following line: https://gitlab.com/gitlab-org/container-registry/-/blob/f6cf4a7d7dacfb5db1130d87398ce4c656c5269d/notifications/listener.go#L165 the listener is trying to stat the filesystem after successfully serving a blob.
In other instances when using the database without filesystem mirroring, the blob listener is never called, however in this case, we use the blobServer
embedded in the repository's linkedBlobStore
to serve all blobs, since they will always be on object storage.
Solution
We should expose a blobServer
from the storage package, but we'll need to wrap the base struct in another type which honors the redirect exceptions for particular repositories, much like linkedBlobStore
currently does. This should isolate the change as much as possible, while reusing the critical logic.