From f5f81942531dbfdf359937686191d2b7f14ec03e Mon Sep 17 00:00:00 2001 From: Mateusz Cikowski Date: Tue, 1 Dec 2026 11:08:16 -0500 Subject: [PATCH 1/2] ci: retry the local registry's image pull while mirror.gcr.io rate-limits it Co-Authored-By: Claude Opus 5.5 --- .github/scripts/infra_build.py | 6 +++--- .github/workflows/local-backends.yml | 12 +++++++----- .github/workflows/publish-pypi.yml | 2 ++ tst/unit/test_infra_build_script.py | 13 +++++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/scripts/infra_build.py b/.github/scripts/infra_build.py index 1e5b2044f..469674c22 100644 --- a/.github/scripts/infra_build.py +++ b/.github/scripts/infra_build.py @@ -95,9 +95,9 @@ _RUNNING = re.compile(r"success: (\S+) entered RUNNING") _PROGRAM = re.compile(r"^\[program:([^\]]+)\]", re.MULTILINE) _PRINTED_CHARS = 200 # of what docker printed in place of a manifest, in the error -# What a registry answers when it rate-limits a request: ECR Public's 429, and the toomanyrequests error code GHCR and -# Docker Hub send. -_RATE_LIMITED = re.compile(r"429 Too Many Requests|toomanyrequests", re.IGNORECASE) +# What a registry answers when it rate-limits a request: ECR Public's 429, the toomanyrequests error code GHCR and +# Docker Hub send, and mirror.gcr.io's per-minute quota error. +_RATE_LIMITED = re.compile(r"429 Too Many Requests|toomanyrequests|Quota exceeded for quota metric", re.IGNORECASE) # What pip in an agent image's build answers for the agentenv-framework-protocol its release published moments earlier, # until PyPI's index, which a CDN caches, lists it: pinned (an agent's), or a floor it names (the browser's recorder). _NOT_YET_SERVED = re.compile(r"No matching distribution found for agentenv-framework-protocol(\[[^\]]*\])?(==|>=)") diff --git a/.github/workflows/local-backends.yml b/.github/workflows/local-backends.yml index 3b0f3814c..591907481 100644 --- a/.github/workflows/local-backends.yml +++ b/.github/workflows/local-backends.yml @@ -128,11 +128,6 @@ jobs: integration-local: runs-on: ubuntu-latest timeout-minutes: 45 - services: - registry: - image: mirror.gcr.io/library/registry:2 - ports: - - 5000:5000 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 @@ -148,6 +143,11 @@ jobs: # the archive to that mirror. - name: Resolve Ubuntu's archive to Azure's mirror run: bash .github/scripts/ubuntu_archive_dns.sh + - name: Start the local registry + run: | + python3 .github/scripts/infra_build.py retry docker pull --quiet mirror.gcr.io/library/registry:2 + docker run --detach --name registry --publish 5000:5000 mirror.gcr.io/library/registry:2 + timeout 30 sh -c 'until curl -sf http://localhost:5000/v2/ >/dev/null; do sleep 1; done' # loadscope keeps a module's or class's tests on one worker, so its fixtures run once, as make int-test-fast does. - name: Integration tier on the local defaults run: | @@ -215,6 +215,7 @@ jobs: restore-keys: packages-${{ matrix.shard }}-${{ steps.week.outputs.week }}- - name: Start the local registry run: | + python3 .github/scripts/infra_build.py retry docker pull --quiet mirror.gcr.io/library/registry:2 docker run --detach --name registry --publish 5000:5000 mirror.gcr.io/library/registry:2 timeout 30 sh -c 'until curl -sf http://localhost:5000/v2/ >/dev/null; do sleep 1; done' # x64 hosted runners have /dev/kvm; the disk form's tests boot under it, and skip without it, which fails below. @@ -297,6 +298,7 @@ jobs: run: bash .github/scripts/ubuntu_archive_dns.sh - name: Start the local registry run: | + python3 .github/scripts/infra_build.py retry docker pull --quiet mirror.gcr.io/library/registry:2 docker run --detach --name registry --publish 5000:5000 mirror.gcr.io/library/registry:2 timeout 30 sh -c 'until curl -sf http://localhost:5000/v2/ >/dev/null; do sleep 1; done' - name: Slow integration tier on the local defaults diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 9272100b5..cd4f074a1 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -412,6 +412,7 @@ jobs: - name: Start the local registry, its storage in a folder handed on run: | mkdir -p "$RUNNER_TEMP/computers/registry" "$RUNNER_TEMP/computers/composed" + python3 .github/scripts/infra_build.py retry docker pull --quiet mirror.gcr.io/library/registry:2 docker run --detach --name registry --publish 5000:5000 \ --volume "$RUNNER_TEMP/computers/registry:/var/lib/registry" mirror.gcr.io/library/registry:2 timeout 30 sh -c 'until curl -sf http://localhost:5000/v2/ >/dev/null; do sleep 1; done' @@ -458,6 +459,7 @@ jobs: merge-multiple: true - name: Serve both registries' storage, which are content-addressed and so merge, as one local registry run: | + python3 .github/scripts/infra_build.py retry docker pull --quiet mirror.gcr.io/library/registry:2 docker run --detach --name registry --publish 5000:5000 \ --volume "$RUNNER_TEMP/computers/registry:/var/lib/registry" mirror.gcr.io/library/registry:2 timeout 30 sh -c 'until curl -sf http://localhost:5000/v2/ >/dev/null; do sleep 1; done' diff --git a/tst/unit/test_infra_build_script.py b/tst/unit/test_infra_build_script.py index f14048494..ab908cc13 100644 --- a/tst/unit/test_infra_build_script.py +++ b/tst/unit/test_infra_build_script.py @@ -647,6 +647,19 @@ def test_retry_tries_again_while_a_registry_rate_limits_it(script, monkeypatch, assert capsys.readouterr().out.count("::warning::a registry rate-limited `docker push img`; trying again in") == 2 +def test_retry_tries_again_while_mirror_gcr_io_is_over_its_quota(script, monkeypatch, capsys): + over_quota = ("docker: error from registry: Quota exceeded for quota metric 'Requests per project in the US " + "multi-region' and limit 'Requests per project in the US multi-region per minute' of service " + "'artifactregistry.googleapis.com'\n") + runs, waits = _attempts(script, monkeypatch, [(over_quota, 1), ("pulled\n", 0)]) + + assert _run(script, monkeypatch, "retry", "docker", "pull", "--quiet", "mirror.gcr.io/library/registry:2") == 0 + + assert len(runs) == 2 and waits == [script._RETRY_WAITS_SECONDS[0]] + assert "::warning::a registry rate-limited `docker pull --quiet mirror.gcr.io/library/registry:2`" in ( + capsys.readouterr().out) + + def test_retry_tries_again_while_pypi_doesnt_list_the_protocol_a_build_installs(script, monkeypatch, capsys): """An agent image's build installs the agentenv-framework-protocol its release published moments earlier.""" missing = ("#13 1.522 ERROR: No matching distribution found for agentenv-framework-protocol[agent]==0.1.359\n" From 4f638f786504b7865eb3eb6e5ad514058abeb829 Mon Sep 17 00:00:00 2001 From: Mateusz Cikowski Date: Tue, 1 Dec 2026 11:11:40 -0500 Subject: [PATCH 2/2] test: every local registry start pulls its image with retry first --- tst/unit/test_release_infra_images.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tst/unit/test_release_infra_images.py b/tst/unit/test_release_infra_images.py index 4ad64d283..d2aa8b501 100644 --- a/tst/unit/test_release_infra_images.py +++ b/tst/unit/test_release_infra_images.py @@ -237,6 +237,20 @@ def test_what_a_registry_can_rate_limit_is_tried_again(): assert JOBS["infra-build"]["strategy"]["max-parallel"] <= 4 +def test_every_local_registry_pulls_its_image_with_retry_before_it_starts(): + """mirror.gcr.io rate-limits anonymous pulls, and a bare ``docker run`` of the registry failed its job on one.""" + pull = "infra_build.py retry docker pull --quiet mirror.gcr.io/library/registry:2" + workflows = {path.name: yaml.safe_load(path.read_text()) for path in (REPO / ".github" / "workflows").glob("*.yml")} + jobs = {(name, job_id): job for name, flow in workflows.items() for job_id, job in flow["jobs"].items()} + starts = [(key, step["run"]) for key, job in jobs.items() for step in job.get("steps", []) + if "--name registry" in step.get("run", "")] + + assert len(starts) == 5 + for key, run in starts: + assert pull in run and run.index(pull) < run.index("docker run"), key + assert not [key for key, job in jobs.items() if "registry" in job.get("services", {})] + + def test_the_folders_a_computers_compose_writes_are_made_before_docker_mounts_one(): """Docker makes a missing folder it mounts root's, and the compose then can't write its record beside it, as v0.9.1544's couldn't."""