Skip to content

Pre-pull Docker images before integration tests start - #100039

Merged
maxknv merged 3 commits into
masterfrom
ci/prefetch-integration-test-images
Mar 20, 2026
Merged

maxknv merged 3 commits into
masterfrom
ci/prefetch-integration-test-images

Conversation

@maxknv

@maxknv maxknv commented Mar 19, 2026 •

Copy link
Copy Markdown
Member

Integration tests pull Docker images on demand inside individual test fixtures.
When the registry is slow or flaky this causes mid-run failures that are
hard to distinguish from real test failures, and wastes time retrying inside
the already-running session.

This change adds a pre-fetch step that runs before any test is executed:

  1. Grep every Python source file in the test suite directories selected for
    the current batch for with_X=True patterns and explicit
    docker_compose_*.yml filename strings.
  2. Map the detected flags to the corresponding compose files in
    tests/integration/compose/ using a small override table for non-obvious
    names (e.g. with_mysql57 → docker_compose_mysql.yml) and the obvious
    docker_compose_{flag}.yml convention for everything else.
  3. Parse image: entries from those compose files, resolving
    ${VAR:-default} placeholders from the environment (tags for
    clickhouse/* images are already set from IMAGES_ENV at this point).
  4. Pull every image with up to 3 attempts (300 s timeout per attempt, 5 s
    sleep between retries). Each pull line logs elapsed time. If any image
    cannot be pulled the job fails immediately with an ERROR status rather
    than letting the failure surface mid-test.

Potential drawback: many integration test jobs start simultaneously, so pre-fetching images up-front from all of them may put extra load on the registry proxy. To mitigate this, the pre-fetch step only pulls images required for the specific job batch rather than the full set. This change may still need to be reverted if the proxy turns out to be overloaded in practice.

Changelog category (leave one):

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

Version info

  • Merged into: 26.4.1.53

Grep test suite sources for `with_X=True` flags and explicit
`docker_compose_*.yml` filename strings to derive the compose files needed
by the current batch, extract all `image:` references (resolving
`${VAR:-default}` placeholders from the environment), then pull every image
with up to 3 retries (300 s timeout per attempt) before any test runs.
If a pull fails the job exits immediately with an ERROR status rather than
surfacing the failure mid-test-run.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a48cd31]

Summary: ✅


AI Review

Summary

This PR adds an integration-test image prefetch stage that scans selected test suites for with_* flags and explicit compose references, resolves image tags, and pre-pulls images in parallel before tests start. I did not find new blocker/major issues in the current diff.

Missing context

  • ⚠️ No CI run results/logs were provided in this review context, so runtime behavior (flake reduction and failure mode quality) was evaluated statically.

ClickHouse Rules

Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ➖
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
Safe rollout ✅
Compilation time ✅

Final Verdict

  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Mar 19, 2026
@maxknv
maxknv force-pushed the ci/prefetch-integration-test-images branch from 19d9497 to f367c38 Compare March 19, 2026 13:42
…p in git

- `_pre_run` prints `git status --short` at job start; if dirty, runs
  `git clean -ffd` to restore a clean workspace before setup begins.
- `_post_run` prints the same at the very end of the job.
- Add `/ci/tmp` to `.gitignore` so the temporary directory used by CI
  jobs does not show up as untracked in local runs.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@maxknv
maxknv force-pushed the ci/prefetch-integration-test-images branch from f367c38 to 253900c Compare March 19, 2026 14:01
Comment thread ci/jobs/integration_test_job.py Outdated
except OSError:
continue
for m in re.finditer(r"^\s+image:\s+(.+)$", content, re.MULTILINE):
resolved = resolve_image(m.group(1).strip())

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.

get_images_from_compose_files captures the whole image: value and keeps inline comments. For tests/integration/compose/docker_compose_coredns.yml, the value is coredns/coredns:1.9.3 # :latest broke this test, so prefetch will execute docker pull with the trailing comment text and fail before tests start.

Please strip inline YAML comments (or parse YAML properly) before pulling. A minimal safe fix here is to remove everything after # for unquoted values before resolve_image.

@maxknv
maxknv marked this pull request as draft March 19, 2026 15:16
Replaces the sequential `prefetch_images` loop in
`ci/jobs/integration_test_job.py` with a new shell script
`ci/jobs/scripts/prefetch-integration-test-images` that:

- Pulls all images in parallel (background subshells + `wait`).
- Treats `no matching manifest` errors as a non-fatal skip rather than a
  failure, so amd64-only images (e.g. `clickhouse/kerberos-kdc`) do not
  abort the job on arm64 runners.

Also fixes `get_images_from_compose_files` to strip inline YAML comments
(e.g. `coredns/coredns:1.9.3 # :latest broke this test`) before passing
the value to `docker pull`.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100039&sha=253900cdb6028e70c4f55b6792a0f251811ad9cd&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%201%2F4%29

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@maxknv
maxknv marked this pull request as ready for review March 20, 2026 10:27
@maxknv
maxknv requested a review from leshikus March 20, 2026 10:27
@leshikus

Copy link
Copy Markdown
Collaborator

Why pre-pulling works better than pulling during the test run? Currently there is a retry for image pulling during the test run (this fix makes it obsolete), and I believe the image won't be pulled second time if needed again - so I just miss the point why this fix is needed.

@leshikus leshikus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We have discussed that in fact this is pre-test infrastructure check, this is quite reasonable to skip tests if infrastructure does not work reliably

@maxknv
maxknv added this pull request to the merge queue Mar 20, 2026
Merged via the queue into master with commit f7dc191 Mar 20, 2026
159 checks passed
@maxknv
maxknv deleted the ci/prefetch-integration-test-images branch March 20, 2026 14:25
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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