fix(container): serve cached images when upstream is unavailable - #199
Merged
Conversation
andrew
force-pushed
the
issue-186-container-offline-auth
branch
from
July 13, 2026 23:42
e982708 to
0ee37c7
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves the OCI (container) proxy’s offline behavior by ensuring previously fetched images remain pullable when the upstream registry or its auth/token service is unavailable. It does this by checking the blob cache before any upstream access, adding persistent manifest caching (including digest aliasing), and serving stale tag manifests on retryable upstream failures.
Changes:
- Add
GetCachedArtifactto support cache-only lookups (no upstream contact) and use it in container blob handling for both GET and HEAD. - Introduce persistent OCI manifest caching with TTL-based revalidation for tags, digest-addressed immutable serving, digest aliasing, and stale fallback on network/429/5xx.
- Extend metadata cache storage to persist
content_digest, including schema migration and tests; update docs to describe the OCI manifest caching exception.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/handler/handler.go | Adds GetCachedArtifact and reuses it in artifact fetch paths. |
| internal/handler/handler_test.go | Updates test helpers to use purl.MakePURLString. |
| internal/handler/container.go | Checks blob cache before upstream for GET/HEAD; routes manifest handling through new caching logic. |
| internal/handler/container_test.go | Adds coverage for bearer challenge discovery and offline/cache behaviors for blobs/manifests. |
| internal/handler/container_manifest.go | Implements manifest caching, TTL revalidation, digest aliasing, and stale serving behavior. |
| internal/database/types.go | Adds ContentDigest to MetadataCacheEntry. |
| internal/database/schema.go | Adds content_digest column + migration. |
| internal/database/queries.go | Updates metadata cache queries/upsert to include content_digest. |
| internal/database/metadata_cache_test.go | Adds tests for digest persistence and migration behavior. |
| docs/configuration.md | Documents OCI manifest caching behavior and TTL/stale semantics. |
| docs/architecture.md | Notes OCI manifests as an exception that are cached automatically for offline pulls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mxey
reviewed
Jul 14, 2026
andrew
force-pushed
the
issue-186-container-offline-auth
branch
2 times, most recently
from
August 13, 2026 06:07
182c537 to
d5d06d7
Compare
andrew
force-pushed
the
issue-186-container-offline-auth
branch
from
August 13, 2026 06:08
d5d06d7 to
75f5da8
Compare
andrew
force-pushed
the
issue-186-container-offline-auth
branch
from
August 13, 2026 06:22
75f5da8 to
52a02c3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Previously cached blobs were unreachable when the Docker Hub token service was down, and manifests were never cached. A previously fetched image therefore could not be pulled when its registry or authentication service was unavailable.
Depends on #198. Once #198 merges, this PR can be retargeted to
main.Fixes #186.
Validation
go test ./... -count=1go test -race ./... -count=1go tool golangci-lint run ./...