fix(mirror): refresh a mirrored tag that upstream re-pushed

Fork CI run 41147980556 pgAdmin#0 failed in sys-ctl-hlth-runtime with
"stalwart_webmail: PHP 8.4.26 is below the security floor 8.4.27".
The deploy ran the fork's GHCR mirror of roundcube/roundcubemail:1.7.5-
apache, copied on 10-19 with PHP 8.4.26, while upstream re-pushed the
same tag on 10-27 with PHP 8.4.27. Branch CI runs the sync with
--only-missing, which skipped the tag because it existed ("destination
exists, skipping") without comparing digests, and the full refresh only
runs on the fork's default branch, which still pins 1.7.4.

- utils/docker/registry.py: manifest_digest() reads the
  Docker-Content-Digest of a reference with a HEAD request, which does
  not count against Docker Hub's pull allowance.
- GHCRProvider.is_stale() reports a mirrored tag as stale only when both
  registries answer with a digest and the two differ.
- Under --only-missing an existing tag is re-copied when it is stale; a
  failed re-copy is reported on stderr with the image and keeps the
  existing copy, so one refresh cannot block every deploy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-31 09:50:14 +01:00
1 parent 8127d61018
commit 79e88c5ea4
7 files changed
+184 -14

No files matched your search

@@ -94,6 +94,46 @@ class TestManifestExists(_IsolatedProbeCache):
self.assertEqual(url, "https://quay.io/v2/keycloak/keycloak/manifests/26.6.3")
class TestManifestDigest(unittest.TestCase):
def test_returns_the_content_digest_of_a_head_request(self) -> None:
with mock.patch.object(
registry.urllib.request,
"urlopen",
return_value=_Resp(
status=200, headers={"Docker-Content-Digest": "sha256:abc"}
),
) as opened:
digest = registry.manifest_digest("roundcube/roundcubemail", "1.7.5-apache")
self.assertEqual(digest, "sha256:abc")
request = opened.call_args.args[0]
self.assertEqual(request.get_method(), "HEAD")
self.assertIn(
"application/vnd.oci.image.index.v1+json", request.headers["Accept"]
)
self.assertEqual(
request.full_url,
"https://registry-1.docker.io/v2/roundcube/roundcubemail/manifests/1.7.5-apache",
)
def test_missing_tag_has_no_digest(self) -> None:
with mock.patch.object(
registry.urllib.request, "urlopen", side_effect=_http_error(404)
):
self.assertIsNone(registry.manifest_digest("postgres", "999"))
def test_rate_limit_has_no_digest(self) -> None:
with mock.patch.object(
registry.urllib.request, "urlopen", side_effect=_http_error(429)
):
self.assertIsNone(registry.manifest_digest("postgres", "16"))
def test_answer_without_digest_header_has_no_digest(self) -> None:
with mock.patch.object(
registry.urllib.request, "urlopen", return_value=_Resp(status=200)
):
self.assertIsNone(registry.manifest_digest("postgres", "16"))
class TestFetchRegistryTags(unittest.TestCase):
def test_anonymous_tags(self) -> None:
with mock.patch.object(