Skip to content

Fix the apt mirror fallback for the Docker image jobs never running - #116444

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-docker-image-apt-mirror-fallback
Aug 26, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-docker-image-apt-mirror-fallback

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Related: #115726

Docker server image and Docker keeper image keep going red on master whenever us-east-1.ec2.ports.ubuntu.com answers 503. Only the arm64 tags fail, because arm64 fetches its .deb packages from ports.ubuntu.com while amd64 uses archive.ubuntu.com:

E: Failed to fetch http://us-east-1.ec2.ports.ubuntu.com/ubuntu-ports/pool/main/o/openssl/openssl_3.0.2-0ubuntu1.29_arm64.deb  503  Service Unavailable
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

ci/jobs/docker_server.py already carries the remedy for exactly this — added in #115726, it rebuilds the image against Canonical's mirror once the retries against the in-region one are used up — but it never ran. terminal_build_failure identifies the step the build stopped on by scanning for buildx's top-level error, matching the literal ERROR: failed to solve:. buildx 0.23 reworded that line to ERROR: failed to build: failed to solve: (measured on 0.30.1), so no terminal step was ever found, is_apt_mirror_failure answered "not the mirror" for every failure, and the fallback was dead code from the day it was added.

This anchors the match on the two parts that did not move — a line that starts with ERROR: and names the solve step — so a future infix cannot break it again. Replaying the failing job's own log through the classifier now returns "try the next mirror", where master returns "no".

Two adjacent errors turned up while checking the classifier against real docker buildx output rather than a canned string: the matched region ran past the closing fence into the Dockerfile source that buildx echoes after it, and it included the step header inside the fence, which repeats the RUN command. Both are recipe text rather than build output, so a RUN line that merely names apt could decide the verdict; the block now ends at the closing fence and the header line is skipped. The fail-closed path is logged now too — being silent is what kept this from being noticed.

The fallback is a working remedy: ports.ubuntu.com answers 200 from an AWS host while us-east-1.ec2.ports.ubuntu.com answers 503, and building the failing step for linux/arm64 against Canonical fetches at 12.7 MB/s and succeeds.

The updated test fails 5 of its arms against master and passes against this change; ci/tests/test_docker_apt_mirror_fallback.py and ci/tests/test_docker_buildx_timeout.py are green (31 passed).

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=887b93e16db98a72906f035e47af9b2ffbf58aa2&name_0=MasterCI&name_1=Docker%20server%20image

Changelog category (leave one):

  • CI Fix or Improvement

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

...


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

`Docker server image` and `Docker keeper image` kept going red on master
whenever `us-east-1.ec2.ports.ubuntu.com` answered `503`. Only the arm64 tags
failed, because arm64 fetches its `.deb` packages from `ports.ubuntu.com` while
amd64 uses `archive.ubuntu.com`:

    E: Failed to fetch http://us-east-1.ec2.ports.ubuntu.com/ubuntu-ports/pool/main/o/openssl/openssl_3.0.2-0ubuntu1.29_arm64.deb  503  Service Unavailable
    E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

`ci/jobs/docker_server.py` already carries the remedy for exactly this - rebuild
the image against Canonical's mirror once the retries against the in-region one
are used up - but it never ran. `terminal_build_failure` identifies the step the
build stopped on by scanning for `buildx`'s top-level error, matching the literal
`ERROR: failed to solve:`. `buildx` 0.23 reworded that line to `ERROR: failed to
build: failed to solve:` (measured on 0.30.1), so no terminal step was ever
found, `is_apt_mirror_failure` answered "not the mirror" for every failure, and
the fallback was dead code from the day it was added.

Anchor the match on the two parts that did not move instead - a line that starts
with `ERROR: ` and names the solve step - so a future infix cannot break it
again. Replaying the failing job's own log through the classifier now returns
"try the next mirror", where master returns "no".

Two adjacent errors, found while checking the classifier against real `docker
buildx` output rather than a canned string: the matched region ran past the
closing fence into the `Dockerfile` source that `buildx` echoes after it, and it
included the step header inside the fence, which repeats the `RUN` command. Both
are recipe text rather than build output, so a `RUN` line that merely names apt
could decide the verdict; the block now ends at the closing fence and the header
line is skipped. The fail-closed path is also logged now - being silent is what
kept this from being noticed.

`ports.ubuntu.com` answers `200` from an AWS host while
`us-east-1.ec2.ports.ubuntu.com` answers `503`, so the restored fallback does
rescue these builds.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=887b93e16db98a72906f035e47af9b2ffbf58aa2&name_0=MasterCI&name_1=Docker%20server%20image
Failed checks on master: https://play.clickhouse.com/play?user=play&tab=Failed%20checks
@clickhouse-gh

clickhouse-gh Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [deaccc6]

Summary: ✅


AI Review

Summary

This PR repairs the apt-mirror fallback in ci/jobs/docker_server.py by matching both the old and new buildx top-level failure wordings and by classifying only the terminal fenced step instead of any stray apt text elsewhere in the log. I did not find an unresolved correctness or coverage gap in the current patch; both the server and keeper image jobs route through this code, and the added regression cases cover the broken wording and the false-positive shapes the old parser missed.

Missing context / blind spots
  • ⚠️ The local environment does not have pytest installed, so I could not run the test files through the normal runner. I validated the changed assertions by importing the modules and executing the test bodies directly, and those checks passed.
Final Verdict
  • Status: ✅ Approve

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Aug 26, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 26, 2026
Merged via the queue into master with commit 792a30d Aug 26, 2026
182 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-docker-image-apt-mirror-fallback branch August 26, 2026 21:00
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 26, 2026
Naz-Ovh pushed a commit to 0x-fork/ClickHouse that referenced this pull request Sep 13, 2026
…an fire

`apt-get update` does not treat a failed repository index fetch as fatal: it
reports the failure at `W:` severity, exits 0, and proceeds with a stale or
absent index. The `RUN` chain therefore continues into `apt-get install`, which
resolves against an index that was never refreshed and dies at `E:` severity with
`E: Unable to correct problems, you have held broken packages`, preceded by
`wget : Depends: libpsl5 (>= 0.16.0) but it is not installable`.

Everything downstream then behaves correctly on the evidence it is handed. buildx
fences the tail of the failing step, which by then holds only the resolution
error; `terminal_build_failure` returns that fence; `is_apt_mirror_failure` finds
no `APT_MIRROR_ERRORS` token at `E:` severity, because the lines that do carry
those tokens are `W:` and sit above the fence; `should_try_next_mirror` returns
False and the mirror loop exits without ever rebuilding against Canonical. The
Canonical fallback is therefore handed exactly the evidence it is designed to
reject, on the outage it exists for.

`--error-on=any` promotes those lines to `E:` and stops the chain before the
install runs, which is the shape the merged classifier was written to recognise.
Nothing in `ci/` changes.

Measured in `ubuntu:22.04` (apt 2.4.14), against a local 503 server and against a
refused port:

  failure shape       apt-get update    rc     severity of the mirror lines
  503 on InRelease    plain             0      W:
  503 on InRelease    --error-on=any    100    E:
  connection refused  plain             0      W:
  connection refused  --error-on=any    100    E:

`any` is apt's only accepted value; `no`, `some` and `warn` each return
`E: Unknown update error mode`.

End to end, with each captured buildx output fed to the shipped
`should_try_next_mirror`:

  docker/server/Dockerfile.distroless   503                  False -> True
  docker/keeper/Dockerfile.distroless   503                  False -> True
  docker/server/Dockerfile.ubuntu       503                  False -> True
  docker/server/Dockerfile.distroless   connection refused   False -> True

The pristine tree reproduces the CI failure byte-for-byte: same failure point
(`Dockerfile.distroless:31`), same `exit code: 100`, same unmet dependency, same
terminal error. Both arms still fail the build, so this changes the
classification, not the outcome of a broken mirror. Control: a full `ch-builder`
build against the real mirrors still succeeds with rc 0 and zero `E:` lines,
exercising all three flagged sites including the `packages.clickhouse.com`
refresh.

The repository already documents this defect on the sibling package manager, in
`docker/server/Dockerfile.alpine` and `docker/keeper/Dockerfile`: "`apk` has no
retry option, and it does not treat a failed repository index fetch as fatal: it
proceeds with an empty index, so every requested package is then reported as
`no such package`". apt behaves the same way and, unlike apk, has an option for
it.

CI report:
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117612&sha=641c9b6831e3c49cc505ac66eed049c46b1f4a4d&name_0=PR&name_1=Docker%20server%20image
Related: ClickHouse#117612
Related: ClickHouse#116444

Co-Authored-By: Claude Opus 5 <[email protected]>
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.

2 participants