fix(image): give every image its own job container release

kaniko runs inside the job container and unpacks the image it builds over it, so the
job container must be the same Ubuntu release as the image's FROM lines. A single
ubuntu:26.04 job container broke the molecule-ubuntu2404 build (run 2529: GLIBC_2.42
not found, then the credential cleanup step died too).

Each matrix entry now names job_image, check_image_versions.py pins fails when it
differs from the Dockerfile's release, the bot-diff guard allows tag and digest edits
of job_image lines, Renovate tracks them with a regex manager (never automerged), and
major ubuntu updates are disabled everywhere: a new release is a deliberate edit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-10-26 18:58:21 +00:00
1 parent 3c471b8986
commit c3d0d7df65
7 files changed
+142 -28

No files matched your search

+3 -3
View File
@@ -11,7 +11,7 @@ When <head-ref> starts with `renovate/`, the diff of <base-ref>...HEAD may only
* images/<name>/Dockerfile: the tag and digest of FROM lines (the image name stays), and
the `uv==<version>` token of a line that holds one;
* .gitea/workflows/image.yml: the matrix `version:` lines, and the tag and digest of the
job container's `image: ubuntu:...@sha256:...` line (the name stays);
job containers' `job_image: ubuntu:...@sha256:...` lines (the name stays);
* .gitea/workflows/{lint,build,molecule}.yml: the version and digest of a
`git.rkdr.net/mortis/<name>:<version>@sha256:<digest>` pin (the name stays), including
the MOLECULE_IMAGE value.
@@ -51,7 +51,7 @@ VERSION_LINE = re.compile(
r"""^\s*(?:-\s*)?version:\s*["']?(?P<v>[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?)["']?\s*(?:#.*)?$""")
FROM_LINE = re.compile(rf"^(FROM\s+(?:--\S+\s+)*)([^\s:@]+)(?::{TAG})?@sha256:[0-9a-f]{{64}}(\s+AS\s+\S+)?\s*$")
UV_TOKEN = re.compile(r"\buv==[0-9][0-9A-Za-z.+!_-]*")
UBUNTU_LINE = re.compile(rf"^(\s*image:\s*ubuntu)(?::{TAG})?@sha256:[0-9a-f]{{64}}\s*$")
UBUNTU_LINE = re.compile(rf"^(\s*job_image:\s*ubuntu)(?::{TAG})?@sha256:[0-9a-f]{{64}}\s*$")
DOCKERFILE = re.compile(r"images/[^/]+/Dockerfile")
CONSUMERS = {".gitea/workflows/lint.yml", ".gitea/workflows/build.yml", ".gitea/workflows/molecule.yml"}
@@ -117,7 +117,7 @@ def file_problem(path, removed, added):
if DOCKERFILE.fullmatch(path):
return same_shape(removed, added, reduce_dockerfile, "the tag or digest of a FROM line or a `uv==` pin")
if path == civ.MATRIX_FILE:
return same_shape(removed, added, reduce_image_yml, "a matrix `version:` or the ubuntu job container pin")
return same_shape(removed, added, reduce_image_yml, "a matrix `version:` or a `job_image:` ubuntu pin")
if path in CONSUMERS:
return same_shape(removed, added, reduce_pin, "an image pin of the mortis registry")
return "is not a file a bot pull request may change"
+59 -4
View File
@@ -18,6 +18,9 @@ pins No file under .gitea/workflows may mention `git.rkdr.net/defame1297/`: the
workflows must name an image of the matrix, with a well-formed digest and a
version that is not newer than the matrix (a pin lags the matrix between the PR
that bumps the version and the PR that moves the pin; it can never lead it).
Every matrix entry names its job container (`job_image: ubuntu:<release>@sha256:...`), and
that release must equal the release of the `FROM ubuntu:` lines of its Dockerfile: kaniko
runs inside the job container and unpacks the image over it.
Offline: whether the tag points at the digest is a registry fact, see the
"unverified" note in the PR description.
bump Fails when the diff <base-ref>...HEAD touches an input of an image without a
@@ -116,11 +119,11 @@ def _scalar(raw, where):
def matrix_of(text):
"""Return {name: {version, subpath, dockerfile}} from the text of image.yml.
"""Return {name: {version, subpath, dockerfile[, job_image]}} from the text of image.yml.
A purpose-built block-style reader, not a YAML parser: the Renovate image has no PyYAML
and the bump step runs there. It reads the single `include:` list and its entries'
`name`, `version`, `subpath` and `dockerfile`, and fails closed (one-line error) on
`name`, `version`, `subpath`, `dockerfile` and `job_image`, and fails closed (one-line error) on
any other shape, so a file it cannot read is never half-understood."""
lines = text.splitlines()
heads = [n for n, line in enumerate(lines) if _INCLUDE_RE.match(line)]
@@ -172,7 +175,7 @@ def matrix_of(text):
raise CheckError(f"a matrix entry of {MATRIX_FILE} lacks the key '{required}' "
"(name, version and dockerfile are required)")
values = {k: _scalar(v[0], f"{MATRIX_FILE} line {v[1]}") for k, v in keys.items()
if k in ("name", "version", "dockerfile", "subpath")}
if k in ("name", "version", "dockerfile", "subpath", "job_image")}
name = values["name"]
if not name or (keys["name"][0].strip()[:1] not in "\"'" and _NUMBER_RE.match(name)):
raise CheckError(f"{MATRIX_FILE}: matrix.include entry {n}: name must be a non-empty string")
@@ -186,6 +189,8 @@ def matrix_of(text):
f"(quote it in the YAML), got {values[key]!r}")
matrix[name] = {"version": values["version"], "subpath": values.get("subpath", ""),
"dockerfile": values["dockerfile"]}
if "job_image" in values:
matrix[name]["job_image"] = values["job_image"]
return matrix
@@ -311,6 +316,54 @@ def check_pins(matrix, consumer_texts):
return errors
JOB_IMAGE_RE = re.compile(r"ubuntu:(?P<release>[0-9]+\.[0-9]+)@sha256:[0-9a-f]{64}")
CONTAINER_LINE_RE = re.compile(r"^\s*image:\s*\$\{\{\s*matrix\.job_image\s*\}\}\s*$", re.MULTILINE)
def dockerfile_releases(dockerfile_text):
"""The `ubuntu:<release>` tags of the FROM lines of a Dockerfile (stage references are skipped)."""
releases = []
for unused, line in _instructions(dockerfile_text):
parts = line.split()
if not parts or parts[0].upper() != "FROM":
continue
refs = [p for p in parts[1:] if not p.startswith("--")]
if not refs:
continue
name, unused, tag = refs[0].split("@")[0].partition(":")
if name == "ubuntu":
releases.append(tag)
return releases
def check_job_images(matrix, read_file, workflow_text):
"""Errors where an image's job container (`job_image`) is not the Ubuntu release its Dockerfile builds.
kaniko runs inside the job container and unpacks the image's root filesystem over it, so a
24.04 image built in a 26.04 job container corrupts the job (run 2529: GLIBC_2.42 not found).
The release of the job container must equal the release of every `FROM ubuntu:` line."""
errors = []
if not CONTAINER_LINE_RE.search(workflow_text):
errors.append(f"{MATRIX_FILE}: the job container must be `image: ${{{{ matrix.job_image }}}}`")
for name, entry in matrix.items():
job = JOB_IMAGE_RE.fullmatch(entry.get("job_image", ""))
if not job:
errors.append(f"image '{name}': job_image in {MATRIX_FILE} must be ubuntu:<release>@sha256:<digest>")
continue
path = str(pathlib.PurePosixPath(entry["subpath"]) / entry["dockerfile"]) if entry["subpath"] else entry["dockerfile"]
try:
releases = dockerfile_releases(read_file(path))
except OSError as exc:
errors.append(f"image '{name}': cannot read {path}: {exc}")
continue
if not releases:
errors.append(f"image '{name}': {path} has no `FROM ubuntu:<release>` line")
for release in sorted(set(releases) - {job["release"]}):
errors.append(f"image '{name}': {path} builds on ubuntu:{release} but its job_image is ubuntu:{job['release']}; "
"kaniko unpacks the image over the job container, so the two releases must be equal")
return errors
def changed_images(head_matrix, changed, read_head_file):
"""{name: sorted touched inputs} for each image of the matrix whose inputs are in `changed`."""
result = {}
@@ -394,11 +447,13 @@ def changed_paths(base_ref, target="HEAD"):
def run(argv):
if len(argv) >= 2 and argv[1] == "pins" and len(argv) == 2:
matrix = matrix_of(pathlib.Path(MATRIX_FILE).read_text())
image_yml = pathlib.Path(MATRIX_FILE).read_text()
matrix = matrix_of(image_yml)
if not pathlib.Path(REQUIRED_CONSUMER).exists():
raise CheckError(f"{REQUIRED_CONSUMER} is missing: it runs this check and is a required consumer")
texts = {f: pathlib.Path(f).read_text() for f in CONSUMERS if pathlib.Path(f).exists()}
errors = check_pins(matrix, texts)
errors += check_job_images(matrix, lambda p: pathlib.Path(p).read_text(), image_yml)
workflows = sorted(pathlib.Path(WORKFLOW_DIR).glob("*.y*ml")) if pathlib.Path(WORKFLOW_DIR).is_dir() else []
errors += check_foreign_images({str(f): f.read_text() for f in workflows})
note = " (checked: " + ", ".join(texts) + ")"