Repository navigation
Do not re-pull integration test images the job already prefetched - #120107
alexey-milovidov merged 7 commits into
Conversation
…d-integration-images
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]>
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
One wording nit stands unfixed and is noted rather than bounced: the comment on the exported list Two alternatives were measured and rejected. Session id: cron:clickhouse-review-slot-48:20260915-030013 |
|
Workflow [PR], commit [98f6199] Summary: ✅ AI ReviewSummaryThis PR teaches the integration job to export the image references it actually pulled and lets Findings
Final VerdictStatus: LLVM Coverage ReportMeasured on commit 98f6199.
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 |
| found = run_and_check( | ||
| ["docker", "image", "inspect", "--format", "{{.Id}}"] + sorted(images), nothrow=True |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 versionexits 1 withunknown flag: --host, both on v2.29.7 (whatclickhouse/integration-tests-runnerships, pinned atci/docker/integration/runner/Dockerfile:73) and on v5.1.3 locally; the same command without--hostexits 0. The flag was a compose v1 option and the plugin does not take it.docker compose --host ... config --imagestherefore exits 1 with 0 bytes on stdout, andrun_and_check(..., nothrow=True)returns stdout only (cluster.py:239), soimagesis empty and_images_prefetched_and_present()returnsFalse.
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.
e55e5d8
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]>
Changelog category (leave one):
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
bcba98b506b55an integration job prefetches the images its batch's compose files declare.ClickHouseCluster.start()then pulls again, per module, anddocker compose pullcontacts the registry for every service image even when it is cached, so one transient denial fails a fixture that needed no download: the same pinnedminio/minioreference 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_pebblepull:setup_letsencrypt_pebbleextendsbase_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.pyerrors 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
pull access deniedappears 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]