mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 22:37:29 +00:00
fix(ci): pull the images the runner uses itself from the GHCR mirror
The GHCR mirror covered role images only. The images the runner pulls on its own went straight to Docker Hub: coredns from compose.yml, the cache stack in compose/cache.override.yml and alpine:latest, the init image of scripts/docker/cache/package-frontend/certs.sh. With the anonymous githubactions quota spent, the guide step of Postmarks#0 (main run 37954203718) and Shopware#2 (#872) died on "toomanyrequests" while pulling alpine:latest, after coredns had hit the same limit. iter_runner_images (utils/docker/image/discovery.py) finds those images, and the mirror sync and the fork-PR wait now cover them next to the role images. On a real GitHub runner compose_file_args layers a generated build/compose/runner-mirror.override.yml that points only the services of the layered compose files at their mirror, and the certificate generator gets the mirrored init image. Local runs and act are unchanged, and the coredns literal stays in compose.yml for Dependabot. test-dns now waits for images-mirror-missing like the deploy and workspace jobs, since it brings up the stack too. Verified with docker compose config on a simulated GitHub runner: the service set is unchanged and only the runner images point at ghcr.io/infinito-nexus/core/mirror/docker.io/..., and an existing role mirror under that scheme pulls anonymously. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
d43b86b022
commit
1ba796d7f1
13 files changed
+436
-8
No files matched your search
@@ -98,9 +98,13 @@ class TestComposeUpRetries(unittest.TestCase):
|
||||
},
|
||||
clear=False,
|
||||
)
|
||||
@patch(
|
||||
"cli.administration.deploy.development.runner_mirror.write_override",
|
||||
return_value="build/compose/runner-mirror.override.yml",
|
||||
)
|
||||
@patch("subprocess.run", autospec=True)
|
||||
def test_run_skips_cache_override_on_github_runner(
|
||||
self, run_mock: MagicMock
|
||||
self, run_mock: MagicMock, _write_override: MagicMock
|
||||
) -> None:
|
||||
compose = self._compose()
|
||||
|
||||
@@ -126,6 +130,8 @@ class TestComposeUpRetries(unittest.TestCase):
|
||||
"compose",
|
||||
"-f",
|
||||
"compose.yml",
|
||||
"-f",
|
||||
"build/compose/runner-mirror.override.yml",
|
||||
"ps",
|
||||
"-q",
|
||||
"infinito",
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from cli.administration.deploy.development import runner_mirror
|
||||
from cli.administration.deploy.development.compose import INIT_IMAGE_KEY, Compose
|
||||
from cli.administration.deploy.development.env import compose_file_args
|
||||
from utils.cache.files import PROJECT_ROOT
|
||||
from utils.cache.yaml import load_yaml_any
|
||||
|
||||
GITHUB = {
|
||||
"GITHUB_REPOSITORY_OWNER": "Acme",
|
||||
"GITHUB_REPOSITORY": "Acme/Core",
|
||||
"INFINITO_GHCR_MIRROR_PREFIX": "mirror",
|
||||
}
|
||||
|
||||
COMPOSE = """\
|
||||
services:
|
||||
coredns:
|
||||
image: coredns/coredns:1.14.4
|
||||
"""
|
||||
|
||||
CACHE_OVERRIDE = """\
|
||||
services:
|
||||
package-cache-frontend:
|
||||
image: nginx:1.27-alpine
|
||||
"""
|
||||
|
||||
|
||||
def _repo(root: Path) -> Path:
|
||||
(root / "compose").mkdir()
|
||||
(root / "compose.yml").write_text(COMPOSE)
|
||||
(root / "compose" / "cache.override.yml").write_text(CACHE_OVERRIDE)
|
||||
(root / "default.env").write_text(
|
||||
"INFINITO_CACHE_PACKAGE_FRONTEND_INIT_IMAGE=alpine:latest\n"
|
||||
)
|
||||
return root
|
||||
|
||||
|
||||
class TestRunnerMirror(unittest.TestCase):
|
||||
@patch.dict(os.environ, GITHUB, clear=False)
|
||||
def test_the_override_covers_only_services_of_layered_files(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = _repo(Path(tmp))
|
||||
relative = runner_mirror.write_override(root, ["compose.yml"])
|
||||
written = load_yaml_any(str(root / relative), default_if_missing={})
|
||||
self.assertEqual(
|
||||
written,
|
||||
{
|
||||
"services": {
|
||||
"coredns": {
|
||||
"image": "ghcr.io/acme/core/mirror/docker.io/coredns/coredns:1.14.4"
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@patch.dict(os.environ, GITHUB, clear=False)
|
||||
def test_the_init_image_resolves_to_its_mirror(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
reference = runner_mirror.env_image(
|
||||
_repo(Path(tmp)), "INFINITO_CACHE_PACKAGE_FRONTEND_INIT_IMAGE"
|
||||
)
|
||||
self.assertEqual(reference, "ghcr.io/acme/core/mirror/docker.io/alpine:latest")
|
||||
|
||||
@patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
**GITHUB,
|
||||
"INFINITO_RUNNING_ON_GITHUB": "true",
|
||||
"INFINITO_GIT_COMMON_DIR": "",
|
||||
"INFINITO_CACHE_STACK": "",
|
||||
"INFINITO_CACHE_NETWORK": "",
|
||||
"INFINITO_PUBLISH_PORTS": "",
|
||||
},
|
||||
clear=False,
|
||||
)
|
||||
def test_a_github_runner_layers_the_mirror_override_last(self) -> None:
|
||||
with patch.object(
|
||||
runner_mirror, "write_override", return_value=runner_mirror.OVERRIDE
|
||||
) as write:
|
||||
args = compose_file_args()
|
||||
write.assert_called_once_with(PROJECT_ROOT, ["compose.yml"])
|
||||
self.assertEqual(args[-2:], ["-f", runner_mirror.OVERRIDE])
|
||||
|
||||
@patch.dict(
|
||||
os.environ, {**GITHUB, "INFINITO_RUNNING_ON_GITHUB": "true"}, clear=False
|
||||
)
|
||||
def test_the_cert_generator_gets_the_mirrored_init_image(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
compose = Compose(_repo(Path(tmp)), "arch")
|
||||
with patch("subprocess.run") as run:
|
||||
compose._generate_package_frontend_certs(
|
||||
{INIT_IMAGE_KEY: "alpine:latest"}
|
||||
)
|
||||
self.assertEqual(
|
||||
run.call_args.kwargs["env"][INIT_IMAGE_KEY],
|
||||
"ghcr.io/acme/core/mirror/docker.io/alpine:latest",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user