Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/scripts/infra_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(\[[^\]]*\])?(==|>=)")
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/local-backends.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
13 changes: 13 additions & 0 deletions tst/unit/test_infra_build_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions tst/unit/test_release_infra_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Loading