Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Reuse compatible main images in pull request tests - #73095

Draft
jason810496 wants to merge 7 commits into
apache:mainfrom
jason810496:ci/image-reuse/05-consumers
Draft

Reuse compatible main images in pull request tests#73095
jason810496 wants to merge 7 commits into
apache:mainfrom
jason810496:ci/image-reuse/05-consumers

Conversation

@jason810496

@jason810496 jason810496 commented Sep 13, 2026

Copy link
Copy Markdown
Member

Part 5/5 of the CI image reuse series.

Why

Avoid rebuilding compatible images while testing the current PR checkout.

How

Enable eligible PR lookups, restore selections through a dedicated script, and build a current-run fallback on misses — including when the selected image's own download is too slow to be worth finishing. Preserve full builds for canaries and dependency upgrades.

Series impact (audit draft)

Sept 6–12, 2026 UTC PR census and CI timing:

Metric Figure
Merged PRs / into main 364 / 240
No dependency-manifest / CI-image / prod-image input changes 218 (90.8%) / 141 (58.8%) / 47 (19.6%)
Full AMD/ARM census execution 17,175.6 h
Image-prep latency, today → 100% hit rate (CI, Py3.10) 19.74 → 5.77 min (−71%)
Latency break-even hit rate ~3.5%
Compute ceiling, cost-free → cost-priced replacement download 106.4 h → ~65.7 h/week
Publisher budget proxy (daily-only cadence) 8.0 h/run → 55.7 h/week
Compute break-even hit rate (daily-only publisher) ~85%

The purpose is to avoid rebuilding the CI image when a PR doesn't change package dependencies — currently, even a PR that only touches the API server or the UI still triggers a full CI image rebuild on every push — and real hit rate and end-to-end PR latency remain unmeasured pending a pilot.

  • Happy path: this PR is what actually removes the build-job wait on a hit, cutting image-prep latency by ~71% (19.74 → 5.77 min for the dominant Python 3.10 CI case). A miss only costs about 30 extra seconds, so even a low cache-hit rate (as little as ~3.5%) already makes this a net time saver overall.
  • Smart fallback: the consumer probes transfer speed over the first 30 seconds of a selected image's download; if that regresses below the upstream reuse floor (which restore_selected_image.sh inherits automatically), it falls back to a regular image build — today's existing behavior — instead of waiting out a degraded transfer.
  • Daily image publish workflow: a centralized periodic workflow (ci/image-reuse/04-publisher) publishes CI and production images, keyed by a fingerprint of build inputs, as GitHub Actions artifacts this PR's lookups consume.
  • Retention: a published artifact is only selected if produced within the last 48 hours, and is retained for 7 days.

Was generative AI tooling used to co-author this PR?

Generated-by: Codex (GPT-6)

Shared CI environments must fail when their locked dependencies cannot be installed, so consumers never reuse a silently re-resolved environment.
Application-only changes should not repeat dependency installation. Separate metadata inputs retain resolver checks while current wheels replace application files.
CI needs a stable compatibility and provenance contract before it can safely reuse an image produced by another workflow run.
A cross-run artifact download that degrades to a crawl instead of
failing outright previously had no circuit breaker: nothing aborted
it, and the consumer would just wait far longer than a fresh build
would have taken. Measure the average transfer rate after the first
30 seconds and abandon the download in favor of building locally
once it falls under 50 MB/s, the rate below which finishing the
transfer is expected to cost more time than it saves.
A retained publisher gives CI a trusted source of compatible environments and dependency caches. Publication must finish successfully and preserve artifacts across retries before consumers can rely on them.
Comment on lines +65 to +76
- name: Fingerprint and resolve
id: resolve
shell: bash
env:
IMAGE_KIND: ${{ inputs.kind }}
IMAGE_PYTHON: ${{ inputs.python }}
IMAGE_PLATFORM: ${{ inputs.platform }}
IMAGE_BASE: ${{ inputs.base-image }}
IMAGE_CONSTRAINTS_FILE: ${{ inputs.constraints-file }}
IMAGE_PUBLISH: ${{ inputs.publish }}
IMAGE_REUSE_DISABLED: ${{ inputs.disabled }}
run: ./scripts/ci/resolve_main_image.sh
Comment on lines +167 to +169
- name: "Install Breeze"
uses: ./.github/actions/breeze
- name: "Resolve compatible main CI image"
Comment on lines +169 to +188
- name: "Resolve compatible main CI image"
id: main-image
if: inputs.use-selected-image || inputs.publish-main-image
uses: ./.github/actions/resolve_main_image
with:
kind: ci
publish: ${{ inputs.publish-main-image }}
python: ${{ matrix.python-version }}
platform: ${{ inputs.platform }}
disabled: >-
${{
!inputs.use-selected-image || !inputs.reuse-main-image || inputs.publish-main-image ||
inputs.push-image == 'true' ||
inputs.upgrade-to-newer-dependencies != 'false' || inputs.docker-cache == 'disabled' ||
inputs.branch != 'main' || inputs.constraints-branch != 'constraints-main' ||
inputs.install-mysql-client-type != 'mariadb' || inputs.debian-version != 'bookworm' ||
inputs.use-uv != 'true' || secrets.CONSTRAINTS_GITHUB_REPOSITORY != '' ||
inputs.image-stash-ref != '' || inputs.seed-cache-from-stashed-image == 'true'
}}
- name: "Publish selected CI image reference"
Installing Breeze before freeing disk space left the venv's Python
symlinked into the runner's hosted toolcache, which the disk-space
script then deletes outright — every later step that shells out to
python3 failed with "No such file or directory" once the space was
freed. Restore the original ordering so cleanup runs first.
Source-only changes should not rebuild compatible environments. Consumers must still run the current checkout and identify a fallback by its workflow run so reuse cannot substitute stale PR code.
@jason810496
jason810496 force-pushed the ci/image-reuse/05-consumers branch from 318e3fc to bc35d1d Compare September 13, 2026 16:18
Comment on lines +167 to +170
- name: "Install Breeze"
uses: ./.github/actions/breeze
- name: "Resolve compatible main CI image"
id: main-image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:production-image Production image improvements and fixes backport-to-v3-3-test Backport to v3-3-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants