Serve cached Dependency Proxy blobs without upstream tokens

What does this MR do and why?

Serve cached Dependency Proxy blobs without requesting a Docker Hub token, so a slow or unavailable auth.docker.io does not delay cached blob downloads.

Keep the token callback on manifests and acquire the token inside the blob cache-miss branch. Return after a rendered token error to preserve the existing status and body without sending Workhorse download instructions. GitLab JWT authentication and group authorization still run before cache access.

References

Closes #635158

Related to #560575 (closed) and !254559 (merged).

Screenshots or screen recordings

Not applicable. This change has no UI.

How to set up and validate locally

  1. In GDK, enable the Dependency Proxy and pull an image through a group to populate its cache.
  2. Obtain a valid Dependency Proxy JWT and a cached layer digest. Make an authenticated GET request to /v2/<group>/dependency_proxy/containers/<image>/blobs/sha256:<digest>.
  3. In the test environment, make outbound requests to auth.docker.io unavailable. Repeat the cached blob request before the GitLab JWT expires. The blob should be served without waiting for a token request.
  4. Request an uncached blob. Token acquisition and its error response should retain their existing behavior. Manifest revalidation still requires upstream access.

These manual outage steps are provided for reviewers; validation performed for this MR is recorded below.

Verification

Run in GDK with Ruby 3.4.10 and the checkout's complete gem bundle:

bundle exec rspec spec/controllers/groups/dependency_proxy_for_containers_controller_spec.rb
# 168 examples, 0 failures (seed 36558)

bundle exec rubocop app/controllers/groups/dependency_proxy_for_containers_controller.rb spec/controllers/groups/dependency_proxy_for_containers_controller_spec.rb
# 2 files inspected, no offenses detected

git diff --check
# Passed

The new cached-blob regression test was also run against the original controller and failed because RequestTokenService.new was called once instead of zero times.

Coverage includes cached local and object-storage downloads, successful cache-miss token forwarding, the cache-miss 503 token error, existing authorization checks, and manifest behavior.

The simplified 503 example was mutation-tested: removing the early return produces a 200 response with an empty body and fails the status/body assertions. A temporary combined snapshot with !254559 (merged) at a95a8e52f79329e56c4a11d60e5de34d80bf5356 also passed 369 controller and dependency-proxy service examples (seed 13701).

MR acceptance checklist

  • Add regression coverage and run the complete controller spec.
  • Run targeted RuboCop and whitespace checks.
  • Review the complete diff with the repository's reviewer workflow.
  • Include Changelog: fixed in the commit.
  • Evaluate documentation: this restores cache behavior without changing configuration or usage; no product documentation update is needed.
  • No database migrations, dependency changes, or feature flags.
  • Obtain CI and maintainer approval.
  • Obtain AppSec review of upstream token acquisition, as required by repository guidance.

/assign me /milestone %19.6

Edited by Thota Shashank

Merge request reports

Loading
Loading