Skip to content

[v3-4-test] Explain a BASE_IMAGE without Python in hardened image builds (#76645) - #76659

Merged
shahar1 merged 1 commit into
apache:v3-4-testfrom
shahar1:backport-76645-v3-4-test
Nov 7, 2026
Merged

shahar1 merged 1 commit into
apache:v3-4-testfrom
shahar1:backport-76645-v3-4-test

Conversation

@shahar1

@shahar1 shahar1 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Backport of #76645. The automatic backport failed.

A plain Debian BASE_IMAGE with the default hardened flavor stops the build with python3: command not found on this branch too, and the legacy flavor the new message points to is published for the 3.4.x line.

The conflict was in dev/breeze/tests/test_os_deps_images.py, which does not exist on v3-4-test. The rest of that file on main tests code that was not backported, so here it holds only the new test. The script reaches the check using bash builtins alone, so the test drops the tool stubs it has on main. The other four files apply unchanged.

Tested: the new test passes, and fails on the unfixed script with exit 127. prek passes at the pre-commit and manual stages, except the shellcheck hook, which could not start Docker in my sandbox, so I ran shellcheck 0.11.0 directly on the script and it reported nothing. breeze build-docs could not run for the same reason, so the docs build is left to CI.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Opus 5.5

Generated-by: Claude Opus 5.5 following the guidelines

🤖 Generated with Claude Code

https://claude.ai/code/session_01BVx6g8K9pmgvCdYRrKCGPk

…lds (apache#76645)

Passing a plain Debian BASE_IMAGE to the default hardened flavor stops the
build with "python3: command not found", which does not say what to change.

dev/breeze/tests/test_os_deps_images.py does not exist on this branch, and the
rest of it on main tests code that was not backported, so it holds only the
new test here. The script reaches the check using bash builtins alone, so the
tool stubs the test has on main are not needed.

(cherry picked from commit 2adbce7)

Claude-Session: https://claude.ai/code/session_01BVx6g8K9pmgvCdYRrKCGPk
@boring-cyborg boring-cyborg Bot added area:dev-tools area:production-image Production image improvements and fixes kind:documentation labels Nov 7, 2026
@shahar1
shahar1 merged commit 5f51c60 into apache:v3-4-test Nov 7, 2026
117 checks passed
potiuk added a commit that referenced this pull request Nov 9, 2026
…ges (#76225)

* Build CI and release images on pinned OS-dependencies images

Pinning the hardened base image to a digest does not pin the dhi.io apt repository the OS dependencies are installed from. It moves on - and drops the package versions it replaced - whenever Docker rebuilds its images, so the same commit could build today and fail tomorrow, and a dhi.io change broke main instead of an upgrade PR. Installing the OS dependencies once, in images built on the mirrored base images and pinned by the same upgrade check, makes day-to-day builds independent of the live repository: a dhi.io change can only break the scheduled image build or the upgrade PR. Standalone builds of the Dockerfile still install from the repositories.

* Build the OS-dependencies images daily instead of on every mirror run

Docker rebuilds the hardened base images several times a day, and rebuilding every OS-dependencies image for each new digest would run a full set of image builds on every mirror run. Building them daily is enough to keep the pinned images close to the apt repository, and the upgrade check no longer triggers builds of its own. As the base image pins now move more often than the OS-dependencies images, the upgrade check pins the latest published image of each Python patch release, whatever base image digest it was built on - the image carries its own Python.

* Fix the legacy PROD image and isolate the OS-dependencies builds

The legacy flavor's runtime OS installation links the compiled Python, so the Python copied from the build image has to be in place before it runs - copying it afterwards broke the legacy image. A cache-disabled build is asked to install everything from scratch, and the CI image's DEPENDENCIES_EPOCH_NUMBER forces reinstallation, so neither may be satisfied by a pinned OS-dependencies image. The daily OS-dependencies builds no longer hold up mirror-only runs, which the upgrade check waits for with a short timeout, and they build on the digests their own run mirrored. Dry runs now print the build plan, and the release image log names the image type again.

* Publish OS-dependencies images ahead of patch releases and pin them on main only

The upgrade check moves the base image pin to a newer Python patch release as soon as the mirror has it, and without OS-dependencies images for that patch release the upgrade PR and main installed from the live apt repository again - the failure the pinned images are there to avoid. Building them for every patch release the mirror copied publishes them before the pin moves. The images are built from main's install script and Dockerfiles, so a release branch pinning them would never match its own installation and would ship both dependency sets; only main pins them until there are images per branch. A dry run of the publication now prints its plan instead of failing on the registry lookups it skips.

* Build each OS-dependencies stage fresh once and record the base image it used

Forcing the whole build fresh made the runtime OS-dependencies image repeat the dev installation it copies the Python distribution from, although the dev image had just been built in the same job. Forcing only the target stage fresh reuses it. An image built on a pinned OS-dependencies image recorded the BASE_IMAGE it was given, while its layers come from the OS-dependencies image, which may be built on an older digest - the images now record which image their OS dependencies came from and the base image those were installed on.

* Keep the pinned OS-dependencies images on cache-disabled build retries

The CI image builds retry with the image cache disabled after any failed first attempt, so tying the pinned OS-dependencies images to a disabled cache sent every retry to the live apt repository - the failure the pinned images avoid. Using them is now its own setting, which only the 'disable image cache' label turns off, and it can be set for a single build.

* Install the database clients with the pinned OS dependencies

The MySQL, MSSQL and PostgreSQL clients were installed after the pinned OS-dependencies layer, so every CI and PROD build still ran apt against the live repositories for them - without the alignment with the dhi.io repository, which the skipped OS installation no longer ran first. Installing them with the OS dependencies puts them in the pinned images, and the marker now covers their scripts and selection, so a different choice reinstalls them. The runtime OS-dependencies build also starts from the dev image built before it rather than repeating the dev installation when that build was skipped or ran in an earlier job.

* Hash the database client scripts and keys into the OS-dependencies image tag

install_os_dependencies.sh now runs the database client scripts, so a change to only one of them, or to a repository key, must produce a new OS-dependencies image. Otherwise the daily build sees the image as already built while every CI and PROD build's marker misses, and each reinstalls from the live repositories until the base image happens to change.

* Document the pinned OS-dependencies images and record the decision in an ADR

The CI images doc did not explain where the OS dependencies of CI and release images come from, and the reasons for pinning them - and the alternatives rejected - were only in PR discussions.

* Build the OS dependencies from the base image when a PR changes their scripts

Reinstalling on top of a pinned OS-dependencies image only exercises additions: a package or database client the change drops stays installed from the pinned layer, so CI could pass while something still depends on it.

* Document that a PR changing the OS-dependency scripts builds from the base image

(cherry picked from commit aa0d650)

Conflicts resolved by hand: the v3-4-test BASE_IMAGE digest is kept, and the breeze help hashes were regenerated from this branch. dev/breeze/tests/test_os_deps_images.py combines the file from #76225 with the test #76659 added, in its main form: with the marker hash from #76225 the script needs cat, cut, dirname and sha256sum before it reaches the Python check.

Generated-by: Claude Opus 5
vatsrahul1001 pushed a commit that referenced this pull request Nov 9, 2026
…lds (#76645) (#76659)

Passing a plain Debian BASE_IMAGE to the default hardened flavor stops the
build with "python3: command not found", which does not say what to change.

dev/breeze/tests/test_os_deps_images.py does not exist on this branch, and the
rest of it on main tests code that was not backported, so it holds only the
new test here. The script reaches the check using bash builtins alone, so the
tool stubs the test has on main are not needed.

(cherry picked from commit 2adbce7)

Claude-Session: https://claude.ai/code/session_01BVx6g8K9pmgvCdYRrKCGPk

Co-authored-by: Jarek Potiuk <[email protected]>
vatsrahul1001 pushed a commit that referenced this pull request Nov 27, 2026
…lds (#76645) (#76659)

Passing a plain Debian BASE_IMAGE to the default hardened flavor stops the
build with "python3: command not found", which does not say what to change.

dev/breeze/tests/test_os_deps_images.py does not exist on this branch, and the
rest of it on main tests code that was not backported, so it holds only the
new test here. The script reaches the check using bash builtins alone, so the
tool stubs the test has on main are not needed.

(cherry picked from commit 2adbce7)

Claude-Session: https://claude.ai/code/session_01BVx6g8K9pmgvCdYRrKCGPk

Co-authored-by: Jarek Potiuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants