Treat a redirected blob HEAD as present in Geo container sync
What does this MR do and why?
With object storage redirects on, a registry answers a HEAD for a linked blob with a 307, not a 200, in legacy and metadata database mode alike. blob_exists? counted only 2xx, so Geo pulled every such blob from the primary and uploaded it again.
Redirects are on by default in Omnibus when object storage is configured.
blob_exists? now counts a 307 as present and does not follow it. The registry sends a 307 only after it confirms the blob is linked in that repository, so a 301 or 302 from a proxy still counts as missing. manifest_exists? has the same 2xx check, but a manifest HEAD answered 200 with redirects on, so it is unchanged.
flowchart TD
H["HEAD blob on the<br/>secondary registry"] --> S{"Status"}
S -- "2xx" --> P["Present, no upload"]
S -- "307, new" --> P
S -- "404, other 3xx or other" --> M["Missing, pull from primary<br/>and upload"]Only the legacy registry was measured. Measured on a two-site Geo pair running 19.5.5-ee, legacy registry on MinIO, re-syncing a 7-blob image after its tag was deleted on the secondary:
| Redirects | Code | HEAD blob | POST upload | PUT blob |
|---|---|---|---|---|
| on | before | 307 x7 | 202 x7 | 201 x7 |
| off | before | 200 x7 | 0 | 0 |
| on | this MR | 307 x7 | 0 | 0 |
on, tags/list failing with 500 |
before | 307 x28 | 202 x28 | 201 x28 |
on, tags/list failing with 500 |
this MR | 307 x28 | 0 | 0 |
References
- Related to work item 641171
- Related to Mount blobs between repositories in Geo container sync, a separate fix for blobs another repository holds
Why no feature flag
Only the registry's own 307, sent after its link check, changes meaning. The registry also rejects a manifest PUT that names a missing blob.
From 19.7, that rejection fails the sync (!253800 (merged)). On 19.4 to 19.6, which lack !253800 (merged), the sync still reports success, so a wrong "present" there would not show as a sync failure.
Screenshots or screen recordings
No UI change.
How to set up and validate locally
On a self-managed Geo pair with a registry on object storage and redirects on, legacy or metadata database:
- Push an image with several layers on the primary and let the secondary sync it.
- On the secondary, in a Rails console, run
container_repository.delete_tag('v1')for that repository. - Run
Geo::ContainerRepositorySync.new(container_repository).execute. - In the secondary registry log, each blob shows a
HEADanswered 307, no blob uploadPOSTor blobPUT, and one manifestPUT.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.
An AI coding assistant wrote this change. The assistant also checked each claim against the source at 85c48579, ran the touched specs and RuboCop on the touched files on a test VM, and ran a ported copy of the change on a two-site Geo test pair.