From a801082d81ea0b279957c9057c7a0a817b142526 Mon Sep 17 00:00:00 2001 From: Jeffrey Sica Date: Tue, 29 Sep 2026 14:00:01 -0500 Subject: [PATCH] ci(track-binaries): refresh amd64 and arm64 pins together, with tests #279 added arm64 sources under `arch == "aarch64"` in k0s-bin.bst and kubeadm-bin.bst after #272's tracker landed. The tracker already treats every `url:` line carrying a component's marker as a pin, so it rewrites the arm64 refs too, but nothing held it to that. Behavioural tests (mocked HTTP) now do: a runc and a k0s bump rewrite both architectures' refs; a release missing the arm64 asset is not a candidate; a missing arm64 asset or checksum fails the component and writes nothing; a no-op run leaves the files byte-identical; the real elements pin arm64 for every amd64 source. The docstring and the tracker docs say so. Assisted-by: Claude Opus 5.5 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/scripts/track-binaries.py | 9 ++- docs/skills/ci-tooling.md | 2 +- docs/skills/kubeadm-sysext.md | 5 +- tests/unit/test_track_binaries.py | 128 ++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+), 4 deletions(-) diff --git a/.github/scripts/track-binaries.py b/.github/scripts/track-binaries.py index bcd2ed01..ca3f88e9 100644 --- a/.github/scripts/track-binaries.py +++ b/.github/scripts/track-binaries.py @@ -9,12 +9,19 @@ kubernetes include/kubeadm.yml kubernetes-version kubelet, kubeadm, kubectl ref: in cri-tools include/kubeadm.yml crictl-version crictl tarball elements/kubeadm/ containerd include/kubeadm.yml containerd-version containerd static tarball kubeadm-bin.bst - runc include/kubeadm.yml runc-version runc.amd64 + runc include/kubeadm.yml runc-version runc. cni-plugins include/kubeadm.yml cni-plugins-version CNI plugins tarball k0s include/k0s.yml k0s-k8s-version and k0s binary ref: in k0s-patch elements/k0s/k0s-bin.bst oras Justfile oras_image tag setup-oras url + checksum in .github/workflows/*.yml +The .bst pins cover every architecture the element fetches: the top-level +amd64 sources and the arm64 ones under `(?): arch == "aarch64"`. Every +`url:` line carrying the component's marker is a pin, wherever it sits, so a +bump refreshes all architectures at once, and a release counts as a candidate +only when every architecture's asset and checksum file is attached. ORAS is +CI tooling and pinned for amd64 runners only. + check Newest release of each component inside its pinned MAJOR.MINOR series: Kubernetes from dl.k8s.io/release/stable-X.Y.txt, the rest from the project's GitHub releases. Drafts, prereleases and releases that lack diff --git a/docs/skills/ci-tooling.md b/docs/skills/ci-tooling.md index 909ccf93..1594d1f3 100644 --- a/docs/skills/ci-tooling.md +++ b/docs/skills/ci-tooling.md @@ -130,7 +130,7 @@ sudo_cmd := if `podman info >/dev/null 2>&1 && echo 1 || echo 0` == "1" { "" } e | `docs` | `docs-checks.yml` | `pull_request`, `push/main` | Runs markdown and skill metadata checks via `docs-checks.py`. Read-only token. | | `reproducibility` | `reproducibility.yml` | `schedule` (Mondays 09:00 UTC), `workflow_dispatch` | Builds the image set, deletes the final-assembly artifacts, rebuilds them without remote caches and diffs every output except `*.gpg` (see "Reproducible builds" in `ddi-installer-build.md`). Throwaway keys, nothing published. Read-only token. | | `unit` | `unit-tests.yml` | `pull_request`, `push/main` | Runs pytest and BATS unit test suites. Read-only token. | -| `check`, `propose` | `track-binaries.yml` | `schedule` (08:30 UTC), `workflow_dispatch` | `check` finds the newest patch release in each pinned series of the upstream binaries pinned by version + sha256 (Kubernetes, cri-tools, containerd, runc, CNI plugins, k0s, ORAS) with `.github/scripts/track-binaries.py`; `propose` moves each version together with its sha256 pins, verified against upstream's checksum files and the downloaded assets, and opens or updates one PR per component on `auto/track-binaries/`. Minor bumps stay manual (`kubeadm-sysext.md`, `k0s-sysext.md`). Read-only `GITHUB_TOKEN`; writes use the mergeraptor app token narrowed to `contents` + `pull-requests` (+ `workflows` for ORAS, pinned in `build.yml`). Never on `pull_request`. | +| `check`, `propose` | `track-binaries.yml` | `schedule` (08:30 UTC), `workflow_dispatch` | `check` finds the newest patch release in each pinned series of the upstream binaries pinned by version + sha256 (Kubernetes, cri-tools, containerd, runc, CNI plugins, k0s, ORAS) with `.github/scripts/track-binaries.py`; `propose` moves each version together with its sha256 pins for every pinned architecture (amd64 and the `arch == "aarch64"` sources), verified against upstream's checksum files and the downloaded assets, and opens or updates one PR per component on `auto/track-binaries/`. Minor bumps stay manual (`kubeadm-sysext.md`, `k0s-sysext.md`). Read-only `GITHUB_TOKEN`; writes use the mergeraptor app token narrowed to `contents` + `pull-requests` (+ `workflows` for ORAS, pinned in `build.yml`). Never on `pull_request`. | GitHub Actions runs the **complete BuildStream compilation pipeline** using `/mnt` SSD storage on the runner for podman and BuildStream caches. Release assets are diff --git a/docs/skills/kubeadm-sysext.md b/docs/skills/kubeadm-sysext.md index 5b44f3ab..fea013a6 100644 --- a/docs/skills/kubeadm-sysext.md +++ b/docs/skills/kubeadm-sysext.md @@ -56,8 +56,9 @@ but never newer. Patch releases change neither constraint. - **Patches** are automatic. `.github/workflows/track-binaries.yml` opens one pull request per component (Kubernetes, cri-tools, containerd, runc, CNI plugins) when a newer patch of its pinned series is out, with the version - and its sha256 refs changed together and checked against the checksum files - upstream publishes. + and its sha256 refs (amd64 and arm64) changed together and checked against + the checksum files upstream publishes. A release missing either + architecture's asset or checksum is not proposed. - **Minors** are manual, once the cluster's control plane runs the new minor: 1. `python3 .github/scripts/track-binaries.py apply kubernetes --version X.Y.Z`, and the same for `cri-tools` (its minor follows Kubernetes). `apply` diff --git a/tests/unit/test_track_binaries.py b/tests/unit/test_track_binaries.py index c75b6b34..90879d41 100644 --- a/tests/unit/test_track_binaries.py +++ b/tests/unit/test_track_binaries.py @@ -423,6 +423,134 @@ def test_github_token_is_sent_to_the_api_and_never_to_downloads(repo, upstream, } +ARM64_OLD = {name: sha(f"{name} arm64".encode()) for name in ("runc", "k0s")} + + +def add_arm64(repo: Path) -> None: + """Give the fixture the real layout's `(?): arch == "aarch64"` sources.""" + bst = repo / "elements/kubeadm/kubeadm-bin.bst" + bst.write_text(bst.read_text().replace("\nconfig:", f""" +(?): +- arch == "aarch64": + sources: + - kind: remote + url: github:opencontainers/runc/releases/download/v%{{runc-version}}/runc.arm64 + ref: {ARM64_OLD['runc']} + directory: runc + +config:""", 1)) + k0s = repo / "elements/k0s/k0s-bin.bst" + k0s.write_text(k0s.read_text().replace("\nconfig:", f""" +(?): + - arch == "aarch64": + sources: + - kind: remote + url: github:k0sproject/k0s/releases/download/%{{k0s-upstream-tag}}/k0s-%{{k0s-upstream-tag}}-arm64 + ref: {ARM64_OLD['k0s']} + +config:""", 1)) + + +RUNC = "https://github.com/opencontainers/runc/releases/download/v1.3.6/" + + +def runc_release(upstream: Upstream, *arches: str) -> dict[str, str]: + new = {} + for arch in arches: + upstream.files[RUNC + f"runc.{arch}"] = f"runc {arch} 1.3.6".encode() + new[arch] = sha(f"runc {arch} 1.3.6".encode()) + upstream.files[RUNC + "runc.sha256sum"] = "".join(f"{d} runc.{a}\n" for a, d in new.items()).encode() + upstream.releases("opencontainers/runc", [ + release("v1.3.6", *(f"runc.{a}" for a in arches), "runc.sha256sum"), + release("v1.3.3", "runc.amd64", "runc.arm64", "runc.sha256sum"), + ]) + return new + + +def test_bump_refreshes_every_architecture_together(repo, upstream): + add_arm64(repo) + new = runc_release(upstream, "amd64", "arm64") + before = snapshot(repo) + + assert track.main(["apply", "runc"], root=repo) == 0 + + assert changed_lines(before, repo) == { + "include/kubeadm.yml": [(' runc-version: "1.3.3"', ' runc-version: "1.3.6"')], + "elements/kubeadm/kubeadm-bin.bst": [ + (f" ref: {OLD['runc']}", f" ref: {new['amd64']}"), + (f" ref: {ARM64_OLD['runc']}", f" ref: {new['arm64']}"), + ], + } + fetched = [r.full_url for r in upstream.requests] + assert RUNC + "runc.amd64" in fetched and RUNC + "runc.arm64" in fetched + + +def test_k0s_bump_refreshes_the_arm64_binary_too(repo, upstream): + add_arm64(repo) + base = "https://github.com/k0sproject/k0s/releases/download/v1.36.4%2Bk0s.1/" + new = {a: upstream.asset(base + f"k0s-v1.36.4%2Bk0s.1-{a}") for a in ("amd64", "arm64")} + upstream.files[base + "sha256sums.txt"] = "".join( + f"{d} *k0s-v1.36.4+k0s.1-{a}\n" for a, d in new.items()).encode() + before = snapshot(repo) + + assert track.main(["apply", "k0s", "--version", "1.36.4+k0s.1"], root=repo) == 0 + + assert changed_lines(before, repo)["elements/k0s/k0s-bin.bst"] == [ + (f" ref: {OLD['k0s']}", f" ref: {new['amd64']}"), + (f" ref: {ARM64_OLD['k0s']}", f" ref: {new['arm64']}"), + ] + + +def test_release_without_its_arm64_asset_is_not_proposed(repo, upstream): + add_arm64(repo) + runc_release(upstream, "amd64") + assert newest("runc", repo) == "1.3.3" + + +def test_missing_arm64_checksum_fails_the_component_and_writes_nothing(repo, upstream, capsys): + add_arm64(repo) + runc_release(upstream, "amd64") + upstream.asset(RUNC + "runc.arm64") # asset exists, but the sums file omits it + before = snapshot(repo) + + assert track.main(["apply", "runc", "--version", "1.3.6"], root=repo) == 1 + + assert snapshot(repo) == before + assert "lists 0 sha256 for runc.arm64" in capsys.readouterr().err + + +def test_missing_arm64_asset_fails_the_component_and_writes_nothing(repo, upstream, capsys): + add_arm64(repo) + new = runc_release(upstream, "amd64", "arm64") + del upstream.files[RUNC + "runc.arm64"] + before = snapshot(repo) + + assert track.main(["apply", "runc", "--version", "1.3.6"], root=repo) == 1 + + assert snapshot(repo) == before + assert new["arm64"] not in (repo / "elements/kubeadm/kubeadm-bin.bst").read_text() + assert f"GET {RUNC}runc.arm64: HTTP 404" in capsys.readouterr().err + + +def test_no_op_run_leaves_multi_arch_files_byte_identical(repo, upstream, capsys): + add_arm64(repo) + upstream.releases("opencontainers/runc", [release("v1.3.3", "runc.amd64", "runc.arm64", "runc.sha256sum")]) + before = {p: (repo / p).read_bytes() for p in FILES} + + assert track.main(["apply", "runc"], root=repo) == 0 + + assert {p: (repo / p).read_bytes() for p in FILES} == before + assert capsys.readouterr().out == "" + + +@pytest.mark.parametrize("name", [n for n, c in track.COMPONENTS.items() if isinstance(c, track.BstComponent)]) +def test_real_elements_pin_amd64_and_arm64_alike(name): + pins = track.COMPONENTS[name].pins(track.Tree(ROOT)) + by_arch = {arch: sorted(p.url.replace(arch, "ARCH") for p in pins if arch in p.url) for arch in ("amd64", "arm64")} + assert by_arch["amd64"] and by_arch["amd64"] == by_arch["arm64"] + assert len(pins) == len(by_arch["amd64"]) * 2 + + @pytest.mark.parametrize("name", list(track.COMPONENTS)) def test_real_pins_are_readable(name): tree = track.Tree(ROOT)