Skip to content

Do not re-pull integration test images the job already prefetched - #120107

Merged
alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:no-repull-prefetched-integration-images
Sep 19, 2026
Merged

alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:no-repull-prefetched-integration-images

Conversation

@groeneai

@groeneai groeneai commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

An integration test module no longer fails when a registry is transiently unavailable for an image the job has already fetched.

Description

Related: #119892, where I observed this (CI report); its diff is not the cause.

Since bcba98b506b55 an integration job prefetches the images its batch's compose files declare. ClickHouseCluster.start() then pulls again, per module, and docker compose pull contacts the registry for every service image even when it is cached, so one transient denial fails a fixture that needed no download: the same pinned minio/minio reference was denied 88 minutes after this job pulled it (log below). That check ran 2,022 passing tests beside one failing fixture; all three retries were denied.

The job now exports only the references it actually pulled, and start() skips the per-module pull only when every image of the project is in that list and still in the daemon. Both halves matter: an unpulled reference may be a stale floating tag; a pulled one can vanish from the shared image store. A genuinely needed fetch still takes the retried pull. The base server image is prefetched too: a batch's detected compose files need not declare it, while a project's own enumeration can. Its failure is not fatal: it only turns the skip off.

I also delete the with_letsencrypt_pebble pull: setup_letsencrypt_pebble extends base_cmd, so the general pull covers it.

#119999 repins those MinIO images, making an absent one fetchable; this stops re-fetching present ones.

Validation: test_userspace_page_cache/test_incorrect_limits.py errors 5/5 on the current path on my box (image on disk, registry denying it) and passes 10/10 with this change, skipping the pull; 5/5 runs with one reference outside the exported set still take it. Dropping either half of the check, exporting the requested set instead of the pulled one, or leaving out the server image each reddens an arm. An S3 and a Pebble module also pass with the pull skipped; an absent Pebble image was still fetched.

Job log excerpt, and the breadth of the denial window
[09:39:39] Pulled minio/minio:RELEASE.2024-09-13T20-26-02Z in 13s    # the job prefetch
[11:08:11] minio1 Error pull access denied for minio/minio           # 88 min later, same daemon, same pinned reference

pull access denied appears in 3,308 integration rows started between 09:28:39Z and 11:03:09Z, spanning 56 pull requests and 48 checks, 739 of them on master.


Workflow [PR]
Sync PR [sync-upstream/pr/120107]

groeneai and others added 7 commits September 14, 2026 13:14
Since bcba98b an integration job resolves every compose file its batch
needs, prefetches all of their images and ends the job if any pull fails.
ClickHouseCluster.start() then ran `docker compose pull` again for every
module, and that command contacts the registry for each service image even
when it is already cached, so one transient registry denial failed a fixture
that needed no download. On one arm_binary shard the job pulled
minio/minio:RELEASE.2024-09-13T20-26-02Z at 09:39:39 and the per-module pull
for the same pinned reference on the same daemon was denied at 11:08:11,
turning a check with 2,022 passing tests red. All three existing retries were
denied, so retrying harder does not help.

Skip the per-module pull when this run's job prefetched and every image of the
project is already in the daemon. Presence is asked of the daemon rather than
delegated to `docker compose pull --policy missing`, which was measured to skip
a present tagged reference but still re-pull an implicit `latest`; this
repository has implicit-latest service images, so that alternative would have
been silently ineffective for them. Anything absent is still pulled, including
an image the prefetch skipped for want of a manifest for the runner's
architecture, and `compose up` pulls a missing image regardless.

`docker image inspect` prints one id per reference it finds, so the count of
ids is compared against the count of distinct references rather than the count
of distinct ids: two present references that share one image id would
otherwise be read as one missing image.

Also delete the with_letsencrypt_pebble pull. setup_letsencrypt_pebble extends
self.base_cmd at add_instance time, so the general pull earlier in the same
start() already covers those images; verified by running a Pebble module with
one of its images absent and observing the single general pull fetch it.

Co-Authored-By: Claude Opus 5 <[email protected]>
The flag records that this job's batch prefetch ran and succeeded, which is
not the same as every declared image being present: the prefetch enumerates
only compose/docker_compose_*.yml, so the per-instance server image is not in
its list, and it silently skips images with no manifest for the runner's
architecture and references it cannot resolve. What makes skipping the
per-module pull safe is the daemon presence check, so say that instead.

Also drop the `--policy missing` note from the call site; it is a refuted
alternative and belongs in the commit message, where it already is.

Co-Authored-By: Claude Opus 5 <[email protected]>
The guard added in c3d0b68 skipped the per-module `docker compose pull`
whenever every reference of the project was present in the daemon. Presence is
not freshness, and the batch prefetch does not cover every reference a project
enumerates: it reads only compose/docker_compose_*.yml, while cluster.py
interpolates instance images into generated per-instance compose files. For a
floating tag outside the prefetch, today's pull re-resolves it against the
registry; the guard would have used whatever an earlier job left on disk.

That case exists in tree. compose/docker_compose_minio.yml resolves
clickhouse/python-bottle to ${DOCKER_PYTHON_BOTTLE_TAG}, which the job asserts
to a content tag, while five modules (test_storage_s3/test_sts.py,
test_storage_delta/test_sts.py, test_storage_s3_queue/test_sts_smoke.py,
test_database_glue/test.py, test_backup_restore_s3_role_arn/test.py) add an
instance with tag="latest" for the same repository. That `:latest` is in
`docker compose config --images` and in no prefetch list, and it can outlive
the job that fetched it: the daemon's storage is the shared
clickhouse_integration_tests_volume and the post-run hook prunes containers and
volumes, not images.

So export the references the prefetch fetched instead of a boolean, and skip
only when the project's references are a subset of them and all are present in
the daemon. Both halves are load-bearing: the prefetch script converts a
missing architecture manifest into success, so a listed reference can still be
absent from the daemon.

The base server image is appended to the prefetch list because it is in every
project's enumeration and in no file under compose/. Without it no project's
references are ever a subset of the prefetched set and the skip never fires,
which was measured: dropping it from the exported set alone puts the module
back to three denied pull attempts and no skip.

Co-Authored-By: Claude Opus 5 <[email protected]>
The prefetch script waives a pull whose reference has no manifest for the
runner's architecture: it prints SKIP and returns 0, so the caller could not
tell a fetched reference from a waived one and exported the whole requested
list. The image store outlives a job (the DinD volume is only container- and
volume-pruned), so a stale local copy of a waived reference satisfied both
halves of the skip predicate and its module's pull was skipped for a reference
this job never fetched, which is not what the change promises.

The script now reports the waived references through PREFETCH_SKIPPED_FILE,
truncating it up front so that an absent report cannot be read as "nothing was
waived"; prefetch_images collects them through skipped_out and treats a missing
report the same way; and the job exports requested minus waived. The report is
written before the failure early-exit, so a run that fails on one reference
still tells the caller what it waived on the others.

The base server image is prefetched by its own non-fatal call rather than being
appended to the batch's fatal one. It is interpolated into the generated
per-instance compose file, so it appears in every project's `docker compose
config --images` while a batch's own compose files need not name it; but a batch
whose instances all pass a custom image= never needs it, and such a batch
previously made no registry request at all. Failing to fetch it now turns the
skip off for that batch instead of ending the job.

Also drops the claim that the server image is in no file under compose/:
docker_compose_clickhouse.yml and docker_compose_keeper.yml do name it, and
neither is ever selected for a batch, which is the real reason the enumeration
misses it.
The report was written in negative polarity: the script recorded what it
waived, the job subtracted that from the requested list, and a missing report
meant "every reference waived". Neither the per-reference record write nor the
aggregating append was checked, and the script has no set -e and returns
success regardless, so a write failure that left the report present but short
made the job export a reference it never fetched. A module holding a stale
local copy of that reference then skipped its pull, which is exactly what the
report exists to prevent.

Reporting what was pulled makes every write failure subtractive: it can only
leave a reference out, and a reference left out is pulled. The report is
published by renaming it inside its own directory, so a reader never sees a
half-written one, and nothing is pre-created, so absence is the only
no-information state and it is the safe one. A reporting failure therefore
costs the optimisation instead of ending a job that would have run fine.

This also removes the waived set, the subtraction and the separate waived
check on the server-image call: that call now contributes to the same set, and
its result no longer needs interpreting, because a pull that neither succeeded
nor was waived simply reports nothing.

The report directory is a TemporaryDirectory rather than a bare mkdtemp, so
each call no longer leaves one behind under ci/tmp.

Co-Authored-By: Claude Opus 5 <[email protected]>
The comment above the server-image pull made two claims that do not hold.

It said a batch whose instances all use a custom image does not need the
default server image. A Keeper-using project enumerates the tagged reference
whatever its instances use: the keeper compose files name
"image: ${image:-clickhouse/integration-test}"
(tests/integration/compose/docker_compose_keeper.yml), and
ClickHouseCluster.setup_keeper_cmd writes
image=clickhouse/integration-test:<DOCKER_BASE_TAG> into the cluster-level env
file that base_cmd interpolates from, which a generated .env confirms:

  keeper_binary=.../build/programs/clickhouse
  keeper_cmd_prefix=clickhouse keeper
  image=clickhouse/integration-test:latest

use_keeper defaults to true, so every with_zookeeper instance takes that path,
including test_replicated_merge_tree_compatibility, where every instance passes
its own image= with a custom tag. A reader trusting the clause could make the
prefetch conditional on the instance images and silently turn the skip off for
every Keeper batch.

It also said the instance image is interpolated into the generated per-instance
compose file. DOCKER_COMPOSE_TEMPLATE carries a literal "image: {image}:{tag}"
filled by str.format when the file is written; compose interpolates nothing
there and needs no env entry, which is why "docker compose config --images"
reports it. Naming the wrong mechanism removed the point of the sentence.

a150fcc carries the same false claim in its own message. History is not
rewritten, so the correction is recorded here instead.

Behaviour is unchanged. The pull was already unconditional and already
non-fatal, and the two revisions of the file are token-identical.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Sep 15, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex) plus my own cold review of the
resulting code, over six rounds: 6 majors agreed and fixed, 12 nits agreed (11 fixed, one
noted below), 10 disagreements with recorded evidence. Severity: ❌ blocker / ⚠️ major / 💡 nit.
DISAGREE verdicts are terminal per finding.

# Sev Finding Verdict Evidence / action
1 ⚠️ Presence in the daemon is not freshness: a reference the job never fetched could be trusted, and a floating tag's local copy can be stale AGREE, fixed Five modules add an instance from a repository the compose files also name, with tag="latest", so docker compose config --images can hold a reference that is in no prefetch list. The job now exports the reference list it pulled, and the skip additionally requires the project's references to be a subset of it
2 ⚠️ A pull waived for a missing architecture manifest, and a short report left by a failed write, could both be exported as fetched AGREE, fixed The script has no set -e and returned success regardless, and the reader trusted any existing report. Fixed by inverting the report rather than by checking writes: it lists the references actually pulled and is published by rename inside its own directory, so a reporting failure can only omit references, which makes the subset test decline and the pull run
3 ⚠️ Prefetching the base server image could end a job that does not need it AGREE, fixed It is a separate non-fatal call: if it fails, the reference is simply not exported and the module pulls as before
4 ⚠️ Three comments and the description claimed more than the code does, one of them that a batch whose instances all use a custom image= never needs the server image AGREE, fixed A Keeper-using project enumerates the tagged reference whatever its instances use: compose/docker_compose_keeper.yml names ${image:-clickhouse/integration-test}, and setup_keeper_cmd writes the tagged value into the cluster-level env file the project interpolates from. Each claim is existential now, with the reasoning in the commit messages
5 ⚠️ The cited fixture cannot prove the pull-skip is live: reverting the change still passes DISAGREE Conceded, and it is why liveness was measured out of band. With the change: zero docker compose pull commands, one skip line, module passes (an S3 and a Pebble module too). Without it: three pull attempts, denial, module errors. Conjunctive oracle, rc=0 AND a skip line AND zero pull commands: 10/10 with, 5/5 red without. Deleting the subset test, or exporting the requested set instead of the pulled one, each reddens exactly one arm
6 💡 docker image inspect does not carry compose's --host, so a custom daemon would be asked the presence question about the default one DISAGREE No caller exists: CLICKHOUSE_TESTS_DOCKERD_HOST is set nowhere in the repository and no test passes custom_dockerd_host=. The prefetch pulls to the default daemon, so that configuration never had prefetch coverage to lose. Worth a ruling if that escape hatch is meant to stay
7 💡 Thirteen further nits: a leaked report directory, a comment block over three lines, a refuted alternative repeated in the diff, two stale phrases in the description, the skip logged at DEBUG, no unit pin for the count contract, shorthand issue links, provenance absent from the commit messages, two un-retried local probes 5 AGREE, fixed / 8 DISAGREE The report directory is a TemporaryDirectory now, the long comment and the repeated alternative moved into the commit message, and the description's stale phrases were rewritten. Declined with evidence: the command the skip replaces logs at DEBUG too and pytest.ini sets log_level = DEBUG; no unit harness imports the cluster helper, and the count contract is pinned by a probe whose mutation reddens exactly the image-alias case; the report URL and the issue link sit in the description, which is what a squash merge keeps; the two probes are local, take 252 ms together, and their failure class is the one the pull already had

One wording nit stands unfixed and is noted rather than bounced: the comment on the exported list
says a reference outside it "was not fetched here", where the exact statement is that it was not
reported as fetched. A reporting failure can only omit references, so the rule that sentence
justifies (a reference outside the list is pulled) holds either way, and the precise contract is
stated in the prefetch_images docstring.

Two alternatives were measured and rejected. docker compose pull --policy missing trusts the cache
for a tagged reference but still re-pulls an implicit latest, and this repository has
implicit-latest service images. Deleting the per-module pull outright and letting
docker compose up -d fetch what is missing is smaller but worse: up has no retry, so the case
that genuinely needs a fetch would lose its retries in exactly the registry-transient window this
change is about.

Session id: cron:clickhouse-review-slot-48:20260915-030013

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Sep 15, 2026
@clickhouse-gh clickhouse-gh Bot closed this Sep 15, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 15, 2026
@groeneai
groeneai requested a review from maxknv September 15, 2026 03:39
@clickhouse-gh

clickhouse-gh Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [98f6199]

Summary: ✅


AI Review

Summary

This PR teaches the integration job to export the image references it actually pulled and lets ClickHouseCluster.start() skip a redundant docker compose pull when every project image is already present locally. The main CI path looks good, but the new skip predicate can consult a different Docker daemon from the one docker compose will actually use, so I would keep this at request-changes.

Findings

⚠️ Majors

  • [tests/integration/helpers/cluster.py:3709-3710] ClickHouseCluster still accepts custom_dockerd_host / CLICKHOUSE_TESTS_DOCKERD_HOST, and self.base_cmd threads that through to docker compose, but this presence probe always runs plain docker image inspect against the default daemon. In that configuration a local prefetched image can make _images_prefetched_and_present() return true even though the target daemon has never seen it, so the retried docker compose pull is skipped and docker compose up performs the first real fetch without retries, reintroducing the false-red path this PR is trying to remove.
    Suggested fix: either run the inspect against the same host as self.base_cmd, or make _images_prefetched_and_present() return False whenever a custom daemon is configured.
Final Verdict

Status: ⚠️ Request changes
Minimum required action: make the prefetched-image presence check use the same Docker daemon as the later compose commands, or explicitly disable the optimization for custom-daemon runs.

LLVM Coverage Report

Measured on commit 98f6199.

Metric Baseline Current Δ
Lines 89.10% 89.10% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.50% 81.50% +0.00%

Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage).

Newly covered: +113 lines in 45 files (-130 lines lost coverage) · Details

Full report

Comment on lines +3709 to +3710
found = run_and_check(
["docker", "image", "inspect", "--format", "{{.Id}}"] + sorted(images), nothrow=True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.base_cmd can target a non-default daemon via custom_dockerd_host / CLICKHOUSE_TESTS_DOCKERD_HOST (__init__ adds --host), but this probe still asks the default daemon. In that configuration a locally prefetched image can make _images_prefetched_and_present() return True even though the daemon that docker compose pull / up will actually use has never seen it, so we skip the retried pull and let compose up do the first real fetch without retries. That reintroduces the transient-registry false-red path this PR is trying to remove.

Could we either run docker image inspect against the same host, or short-circuit this optimization whenever a custom daemon is configured?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The presence check's first command is self.base_cmd + ["config", "--images"], so it is already keyed to the same daemon spec as the later compose commands, and an empty result returns False before docker image inspect is reached. Measured, that is what happens in the configuration you describe:

  • docker compose --host unix:///var/run/docker.sock version exits 1 with unknown flag: --host, both on v2.29.7 (what clickhouse/integration-tests-runner ships, pinned at ci/docker/integration/runner/Dockerfile:73) and on v5.1.3 locally; the same command without --host exits 0. The flag was a compose v1 option and the plugin does not take it.
  • docker compose --host ... config --images therefore exits 1 with 0 bytes on stdout, and run_and_check(..., nothrow=True) returns stdout only (cluster.py:239), so images is empty and _images_prefetched_and_present() returns False.

So a custom_dockerd_host run never reaches the skip: the retried pull runs, and fails at flag parsing exactly as it does on master. Adding the short-circuit would gate a branch that is already off, and there is no caller either: nothing passes custom_dockerd_host=, and CLICKHOUSE_TESTS_DOCKERD_HOST appears only in its own os.environ.get (cluster.py:648-650).

Pointing the tests at another daemon through DOCKER_HOST stays consistent, because the plain docker image inspect honors it too: with DOCKER_HOST=unix:///nonexistent/x.sock the inspect exits 1 with failed to connect to the docker API at unix:///nonexistent/x.sock, and exits 0 against the default socket.

Leaving the code as it is.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 19, 2026
Merged via the queue into ClickHouse:master with commit e55e5d8 Sep 19, 2026
176 of 348 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 19, 2026
VighneshPath pushed a commit to VighneshPath/ClickHouse that referenced this pull request Nov 23, 2026
Port of ClickHouse#120107.

`docker compose pull` asks the registry about every service image even when
the daemon already has it, so a transient denial fails a module that needed
no download. Skip that pull only when every image of the project is one this
job actually pulled and is still present.

The default server image on this branch is `altinityinfra/integration-test`.

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

Labels

can be tested Allows running workflows for external contributors comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants