Serve cached images when the registry is unreachable

What does this MR do and why?

Keep cached Dependency Proxy images available when Docker Hub authentication or registry requests fail. A failed token request previously stopped the manifest request before the cache lookup could run.

  • Return HTTP 503 with reason: :upstream_request_failed for request exceptions in RequestTokenService and HeadManifestService, replacing the nonstandard 599 marker.
  • Use the failure reason to allow cache fallback, while preserving actual upstream token responses such as 401 and 503.
  • Omit the Authorization header when there is no upstream token.
  • Log handled exceptions with image context, and remove the unreachable manifest rescue and 503 branch.

Cached blobs already bypass upstream token requests after the related cached-blob MR merged. Uncached pulls still require the upstream registry and can fail with a standard HTTP response, such as 401 or a Workhorse 502/504. Cache retention is unchanged.

References

Fixes #560575 (closed)

Related merged change: !264118 (merged)

Screenshots or screen recordings

Not applicable: no UI changes.

How to set up and validate locally

Use a development instance with Dependency Proxy enabled for a group. These manual outage checks have not been run in this session.

  1. Authenticate Docker to the group's Dependency Proxy and pull an image through it to populate the manifest and blob cache.
  2. Make Docker Hub's auth and registry endpoints unreachable from that development instance, using its test proxy or network controls.
  3. Pull the same image through Dependency Proxy and confirm the cached pull succeeds.
  4. Pull an uncached image and confirm it fails with a standard HTTP error rather than 599.
  5. Restore upstream connectivity and confirm normal pulls work again.

MR acceptance checklist

Evaluate against the MR acceptance checklist.

Local automated validation: 492 examples passed across the controller, Enterprise Edition controller, and all Dependency Proxy service specs. RuboCop passed for all nine changed Ruby files, and whitespace checks passed. Coverage includes cache fallback, tracking events, missing-token headers, exception logging, and the distinction between request exceptions and actual upstream 503 responses.

A Changelog: fixed trailer is included. No database, UI, or dependency changes.

Edited by Tri Lam

Merge request reports

Loading
Loading