Skip to content
Merged
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
7 changes: 5 additions & 2 deletions .github/scripts/infra_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
# What GHCR answers a push to a new package while another platform's push creates it, until it links the package to
# this repository.
_NOT_YET_LINKED = re.compile(r"denied: permission_denied: write_package")
# The commands that push: an image, and an index joined in the registry, which pushes its platforms' manifests at once.
_PUSHES = (["docker", "push"], ["docker", "buildx", "imagetools", "create"])
# How long to wait before each try again, so a burst of builds starting together spreads out.
_RETRY_WAITS_SECONDS = (30, 60, 120)

Expand Down Expand Up @@ -436,13 +438,14 @@ def _why_again(result: subprocess.CompletedProcess) -> str | None:
"""Why a failed run can work later, or None: a registry rate-limited it, as public.ecr.aws does past one anonymous
pull a second, which builds starting together pass; a build's pip can't find the agentenv-framework-protocol its
release has just published, which PyPI's index lists a little after the upload; or GHCR refuses a push to a package
another platform's push is creating, as an image's first release pushes both at once."""
another platform's push is creating, as an image's first release pushes both at once, and as a computer app's first
index pushes both its images."""
printed, command = f"{result.stdout}{result.stderr}", f"`{' '.join(result.args)[:_PRINTED_CHARS]}`"
if _RATE_LIMITED.search(printed):
return f"a registry rate-limited {command}"
if _NOT_YET_SERVED.search(printed):
return f"PyPI doesn't list yet the agentenv-framework-protocol {command} installs"
if list(result.args[:2]) == ["docker", "push"] and _NOT_YET_LINKED.search(printed):
if any(list(result.args[:len(push)]) == push for push in _PUSHES) and _NOT_YET_LINKED.search(printed):
return f"GHCR doesn't let this repository write yet the package {command} pushes to"
return None

Expand Down
15 changes: 15 additions & 0 deletions tst/unit/test_infra_build_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,21 @@ def test_retry_tries_again_a_push_ghcr_refuses_while_another_platform_creates_th
in capsys.readouterr().out)


def test_retry_tries_again_an_index_ghcr_refuses_while_its_first_image_creates_the_package(script, monkeypatch, capsys):
"""A computer app's first index pushes both its images at once, as v0.9.1545's chromium did."""
denied = ("ERROR: copy sha256:a84f from localhost:5000/agentenv-computers@sha256:a84f to "
"ghcr.io/scaleapi/agentenv-chromium:index-b4f4: failed commit on ref \"manifest-sha256:a84f\": "
"unexpected status from PUT request to "
"https://ghcr.io/v2/scaleapi/agentenv-chromium/manifests/sha256:a84f: 403 Forbidden\n"
"denied: permission_denied: write_package\n")
runs, waits = _attempts(script, monkeypatch, [(denied, 1), ("pushed\n", 0)])

assert _run(script, monkeypatch, "retry", "docker", "buildx", "imagetools", "create", "-t", "index", "a", "b") == 0

assert len(runs) == 2 and waits == [script._RETRY_WAITS_SECONDS[0]]
assert "::warning::GHCR doesn't let this repository write yet the package" in capsys.readouterr().out


def test_retry_doesnt_try_again_a_denied_command_that_isnt_a_push(script, monkeypatch, capsys):
runs, waits = _attempts(script, monkeypatch, [("denied: permission_denied: write_package\n", 1)])

Expand Down
Loading