Registry Proxy: Future Work and Known Issues¶
Status: Proposed. Written 2026-06-20 as the follow-up list for
PLAN-registry-proxy.md, and left in the
repository root until 2026-12-01, when it was moved here and
registered. The pull-through proxy and --layer-cache have since
shipped, and the mix_stderr known issue has been handled in the
tests, but HEAD-based cache invalidation, the layer cache unit
tests and the pull-through functional test are still open. This
document predates PLAN-TEMPLATE.md, so it does not carry the
Prompt, Situation and Mission sections a new plan would.
Known Issues¶
CliRunner mix_stderr in tests¶
Click 8.x defaults CliRunner(mix_stderr=True), which mixes
stderr (logging) into result.output and result.stdout. Tests
that parse JSON from result.stdout after real (non-mocked) I/O
will fail if the command produces log output. Fixed for
test_check_tar_source by using CliRunner(mix_stderr=False).
Other JSON-parsing tests currently pass because they mock
PipelineBuilder (suppressing real I/O), but any new test that
exercises real I/O and parses JSON from stdout should use
mix_stderr=False.
Planned Work¶
1. Cache Invalidation (HEAD-based freshness)¶
Design¶
On a downstream cache hit, HEAD the upstream manifest to compare
Docker-Content-Digest. If the digest differs, treat as a cache
miss and re-fetch/re-filter/re-push.
New CLI option: --upstream-check-interval N (default 0 = check
every request). When N > 0, skip the HEAD check if the last
check for that repo:tag was < N seconds ago.
Changes to occystrap/proxy.py¶
_ProxyState.__init__ -- add fields:
self.upstream_check_interval = upstream_check_interval
self.upstream_check_times = {} # 'repo:tag' -> timestamp
self.pull_cache_stale = 0 # stale cache stat
New _get_upstream_image(repo_name) -- create/cache
input_registry.Image instances for upstream (mirrors
_get_downstream_image). Needed for HEAD requests.
New _upstream_manifest_url(repo_name, tag) -- build
upstream URL using same pattern as _downstream_url but with
self.state.upstream_uri.
New _check_upstream_freshness(repo_name, tag,
downstream_digest):
1. Check interval: if last check < N seconds ago, return True
(still fresh)
2. Create/get upstream Image via _get_upstream_image()
3. HEAD upstream manifest URL
4. Compare Docker-Content-Digest from upstream with
downstream_digest
5. Update upstream_check_times[repo:tag] timestamp
6. Return True if digests match (fresh), False if stale
7. On upstream HEAD failure (exception): return True (assume
fresh -- don't break serving on upstream unavailability)
Modify _handle_pull_manifest -- after successful
downstream GET (cache hit), before serving:
# After: resp = downstream_img.request_url('GET', ...)
downstream_digest = resp.headers.get(
'Docker-Content-Digest')
if not self._check_upstream_freshness(
repo_name, tag, downstream_digest):
# Stale -- fall through to cache miss path
with self.state.lock:
self.state.pull_cache_stale += 1
pass # don't return, continue to lock+refetch
else:
# Fresh -- serve from cache
with self.state.lock:
self.state.pull_cache_hits += 1
self.state.images_pulled += 1
self._proxy_downstream_response(resp)
return
Same pattern for the double-check after lock acquisition.
run_proxy() -- add upstream_check_interval=0 parameter,
pass to _ProxyState. Log pull_cache_stale at shutdown.
Changes to occystrap/main.py¶
Add to proxy_cmd:
@click.option('--upstream-check-interval', default=0,
type=int,
help='Seconds between upstream freshness'
' checks (0=always, default: 0)')
run_proxy().
Unit tests (in test_proxy.py)¶
- test_freshness_check_serves_when_fresh: Downstream hit, upstream HEAD returns same digest -> serve from cache
- test_freshness_check_refetches_when_stale: Downstream
hit, upstream HEAD returns different digest -> re-fetch from
upstream, increment
pull_cache_stale - test_freshness_check_interval_skips: With interval=60, second request within 60s skips upstream HEAD
- test_freshness_check_upstream_failure_serves_cache: Upstream HEAD raises exception -> serve cached (graceful degradation)
2. Layer Cache Unit Tests¶
Test class: TestLayerCacheProxy (in test_proxy.py)¶
-
test_layer_cache_passed_to_pipeline: Push an image through the proxy. Mock
PipelineBuilder.build_outputto capture thelayer_cacheandfilters_hashkwargs. Verify non-None layer_cache is passed whenstate.layer_cacheset. -
test_layer_cache_not_passed_without_config: When
state.layer_cacheis None, verifybuild_outputreceiveslayer_cache=None. -
test_filters_hash_computed: Push with filters set. Verify
filters_hashpassed tobuild_outputis a sha256 hex string (not 'none'). -
test_filters_hash_none_without_filters: Push without filters. Verify
filters_hash='none'. -
test_layer_cache_shared_across_images: Push two images. Verify both calls to
build_outputreceive the sameLayerCacheinstance. -
test_pull_through_uses_layer_cache: Pull-through an image with layer_cache set. Mock
PipelineBuilder.build_outputto verify layer_cache is passed for pull path too.
3. Functional Tests¶
CI changes (.github/workflows/functional-tests.yml)¶
Add second registry container after existing registry start:
New file: deploy/occystrap_ci/tests/test_pull_through.py¶
Helper: _start_proxy(...) -- starts occystrap proxy as
a subprocess, polls GET /v2/ until ready (timeout 10s),
returns the subprocess. Uses --insecure for localhost
registries.
Helper: _stop_proxy(proc) -- sends SIGTERM, waits up to
10s, kills if needed.
Test class: PullThroughTestCase(testtools.TestCase)
Uses:
- Upstream: localhost:5000 (populated with test images)
- Downstream: localhost:5001 (empty cache registry)
- Proxy: 127.0.0.1:PORT (ephemeral port via --listen)
test_pull_through_serves_image:
1. Start proxy with --upstream localhost:5000
--downstream localhost:5001
2. Pull library/busybox:latest through proxy using
occystrap process registry://127.0.0.1:PORT/...
tar://temp.tar --insecure
3. Verify exit code 0
4. Verify tarball is valid via occystrap check tar://temp.tar
5. Stop proxy
test_pull_through_populates_downstream:
1. Start proxy, pull image through it
2. Verify image exists in downstream:
occystrap info --insecure
registry://localhost:5001/library/busybox:latest
3. Stop proxy
test_pull_through_with_filter:
1. Start proxy with -f normalize-timestamps
2. Pull image through proxy to tarball
3. Check tarball passes validation
4. Stop proxy
test_pull_through_blob_get: 1. Start proxy, pull manifest through proxy 2. Extract a blob digest from the manifest 3. GET blob through proxy, verify 200 4. Stop proxy
test_cache_hit_on_second_pull: 1. Start proxy, pull image (populates downstream) 2. Pull same image again 3. Both succeed 4. Stop proxy
Files Modified¶
| File | Changes |
|---|---|
occystrap/proxy.py |
Freshness check, upstream Image cache, check interval, stats |
occystrap/main.py |
--upstream-check-interval option |
occystrap/tests/test_proxy.py |
Freshness tests, layer cache tests |
deploy/occystrap_ci/tests/test_pull_through.py |
New: functional pull-through tests |
.github/workflows/functional-tests.yml |
Add second registry on port 5001 |
Implementation Sequence¶
- Cache invalidation:
_ProxyStatefields,_get_upstream_image,_upstream_manifest_url,_check_upstream_freshness, modify_handle_pull_manifest, CLI option,run_proxyparam - Cache invalidation unit tests
- Layer cache unit tests
- CI workflow change (add second registry)
- Functional test file + tests
- Update documentation (ARCHITECTURE.md, AGENTS.md, README.md, command-reference.md, PLANS-registry-proxy-future.md)
- Run
pre-commit run --all-files
Verification¶
# Unit tests
tox -epy3 -- test_proxy
# All pre-commit hooks
pre-commit run --all-files
# Functional tests (CI only, requires Docker + two registries)
cd deploy && stestr run test_pull_through
Deferred Work¶
containerd-snapshotter TLS compatibility¶
Docker's containerd-snapshotter: true feature (default on some
distributions, including the kerbside-patches CI runners) causes
Docker to use containerd's own push resolver for image pushes.
This resolver ignores Docker's insecure-registries daemon.json
setting, always attempting HTTPS even to 127.0.0.1. The error
manifests as:
We tried three approaches, none of which worked:
insecure-registriesin daemon.json -- ignored by containerd's push resolver- containerd
hosts.tomlat/etc/containerd/certs.d/127.0.0.1:5050/hosts.tomlwithserver = "http://127.0.0.1:5050"-- not read by Docker's containerd integration (Docker doesn't use CRI) - CRI
config_pathin/etc/containerd/config.toml-- Docker doesn't use the CRI plugin, so this has no effect
The current workaround in kerbside-patches CI is to replace
daemon.json entirely, dropping containerd-snapshotter: true so
Docker uses its native push path which honors insecure-registries.
Possible future solutions to investigate:
- HTTPS proxy mode: Add
--tls-cert/--tls-keyoptions tooccystrap proxy(or auto-generate a self-signed cert likedockerpush://does). Docker skips cert verification for127.0.0.0/8regardless of snapshotter setting, so HTTPS with a self-signed cert would work universally. - Docker source code: Investigate how Docker's containerd
image store resolver (
daemon/containerd/in moby) discovers registry host configuration. There may be a mechanism we missed, or a future Docker release may fix this. - containerd transfer service config: containerd 2.x has a transfer service that may have its own registry config path separate from CRI. This needs investigation.
Multi-architecture support¶
Both push and pull paths reject manifest lists (multi-arch images) with a 400 error. Supporting multi-arch would require:
- Parsing manifest list to identify platform-specific manifests
- Processing each platform manifest independently
- Reassembling and pushing the manifest list to downstream
This is tracked in PLAN-compatibility.md as Priority 3.