Repository navigation
Rebuild against Canonical when the in-region apt mirror is broken - #115726
Conversation
The `Docker server image` check went red on master because `us-east-1.ec2.ports.ubuntu.com` answered `503 Service Unavailable` for `tzdata` and served the other packages at ~20 kB/s. The arm64 server image burned all five `BUILDX_RETRIES` against that one mirror over 15 minutes and still failed; the mirror only recovered about ten minutes later, and the same degraded window took out five unrelated pull requests the same night. `--apt-mirror-region`, added in 47dee58, exists because the opposite happens too: Canonical's `archive.ubuntu.com` and `ports.ubuntu.com` are frequently unreachable over IPv4 from the runners. So neither mirror can be trusted on its own, and retrying one of them harder cannot fix either failure mode. Keep the in-region mirror as the first choice, and when an image exhausts its retries on an apt *download* failure, rebuild it once against Canonical instead of reding the check. The mirror is already a `--build-arg`, so this is confined to the CI job: the published `docker/server` and `docker/keeper` Dockerfiles are untouched and still default to Canonical, as intended by 7cb4072. The second attempt is reached only through `APT_MIRROR_ERRORS`, which are the signatures of a mirror not handing over a file. A broken package name, an unsatisfiable dependency or any other genuine packaging error produces none of them and still fails on the first attempt, so the narrowed retry allowlist from pull request 108969 keeps its fail-fast property. Alpine images are unaffected: `apk` failures do not print any of these strings. Measured over 180 days of CI, restricted to apt download failures in the `Docker server image` and `Docker keeper image` checks: 82 failed image builds across 12 bursty days. The nine since the in-region mirror was adopted are all arm64, that is, all on `ports.ubuntu.com`. Validated by building the exact failing layer on an aarch64 host with the in-region mirror pointed at a region that does not resolve: the build fails twice against the dead mirror, is rebuilt against `ports.ubuntu.com` and succeeds. Also checked that a genuine build error still fails on the first attempt with no second mirror tried, that a healthy build issues exactly one buildx invocation per architecture as before, and that without `--apt-mirror-region` nothing changes. The package that 503'd, `tzdata_2026c-0ubuntu0.22.04.1_all.deb`, downloads fine from Canonical. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=096ba6c83084966d9be3b14d660db1b5186c8b12&name_0=MasterCI&name_1=Docker%20server%20image&name_1=Docker%20server%20image Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [3f7dd83] Summary: ✅ AI ReviewSummaryThis PR adds a second Missing context / blind spots
Findings
Final VerdictChanges requested. |
…r-fallback # Conflicts: # ci/jobs/docker_server.py
Review feedback: `is_apt_mirror_failure` matched `APT_MIRROR_ERRORS` anywhere in `Result.info`, which is the whole `--progress=plain` build log. An `apt-get update` that missed an index and carried on leaves `W: Failed to fetch` and `Some index files failed to download` in the log of a step that *succeeded*, so any later failure in that image - a misspelled package, an unsatisfiable dependency - looked mirror-related and was rebuilt against Canonical. That both spends a whole image build on a failure no mirror can fix and buries the real error behind it, losing the fail-fast property the narrowed retry allowlist exists for. Two things now narrow the match. `terminal_build_failure` returns only the fenced context block that buildx prints for the step it stopped on, taken from the last `ERROR: failed to solve:` so a retried build is judged by its final attempt; a log without that shape yields nothing and the fallback is not reached, because `Result.info` is capped at 300 lines and may be re-centred on the first `: error:` line. Inside the block, apt's own severity decides: `W:` is a miss apt recovered from, `E:` is the file it could not get, which also separates the two when `apt-get update && apt-get install` share one step. Merging master brought in the per-invocation `timeout` from pull request 115572, which changes what the mirror failure looks like: `Acquire::http::Timeout` is an inactivity timeout, so the mirror that trickles bytes - the 2026-08-21 failure this whole change is about - never produces an apt error at all and is killed by the bound instead. An expiry therefore also has to reach the next mirror, via `should_try_next_mirror`, while a bare 137 (OOM, external kill) still must not. The extra attempt is reached only once the build is failing anyway, and `buildx_timeout` shrinks each bound by the elapsed time, so the job stays inside its own cap. `ci/tests/test_docker_apt_mirror_fallback.py` pins all of it: the false positive above, the mixed-severity step, the fail-closed unrecognized log, the last-attempt rule, the timeout arm, the mirror order, and that the loop is wired to the classifier - driving the real `build_and_push_image` and asserting the second invocation is a rebuild against the other mirror, that a packaging error still issues one command, and that without `--apt-mirror-region` nothing changes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| def is_apt_mirror_failure(info: str) -> bool: | ||
| """Did the step that stopped the build fail because a mirror withheld a file?""" | ||
| return any( | ||
| APT_ERROR_SEVERITY in line and any(error in line for error in APT_MIRROR_ERRORS) |
There was a problem hiding this comment.
is_apt_mirror_failure still treats any apt fetch failure as if it came from the Ubuntu mirror we are switching. Both docker/server/Dockerfile.ubuntu and docker/server/Dockerfile.distroless later run apt-get against packages.clickhouse.com, and a 503 there produces the same E: Failed to fetch ... / E: Unable to fetch some archives pair, so this returns True even though the retry only changes apt_archive / apt_ports_archive. That burns a full rebuild on a failure Canonical cannot fix. Could we key the fallback on the failed URL host (or at least on the specific base-image apt step) instead of any apt fetch error?
| has to reach the next mirror too - it is only reached once the build is failing | ||
| anyway, and `buildx_timeout` keeps the extra attempt inside the job's own cap. | ||
| """ | ||
| return is_apt_mirror_failure(info) or is_buildx_timeout(info) |
There was a problem hiding this comment.
The timeout arm widens the fallback to every docker buildx expiry, not just timeouts in an apt step. build_and_push_image passes apt_mirror_region through every os, so an alpine timeout or a timeout in the direct-wget path also reaches the second mirror even though the second command changes no input relevant to the failing step. I reproduced this with os='alpine': the code emits a second docker buildx for Dockerfile.alpine, and the only delta is dropping the unused apt_* build args. Could we gate the timeout fallback to apt-based images / steps instead of all build expiries?
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
Related: #104152
Related: #108969
The
Docker server imagecheck went red on master becauseus-east-1.ec2.ports.ubuntu.comanswered503 Service Unavailablefortzdataand served the other packages at ~20 kB/s. The arm64 server image burned all fiveBUILDX_RETRIESagainst that one mirror over 15 minutes and still failed; the mirror recovered about ten minutes later, and the same degraded window took out five unrelated pull requests the same night.Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=096ba6c83084966d9be3b14d660db1b5186c8b12&name_0=MasterCI&name_1=Docker%20server%20image&name_1=Docker%20server%20image
--apt-mirror-region, added in 47dee58, exists because the opposite happens too: Canonical'sarchive.ubuntu.comandports.ubuntu.comare frequently unreachable over IPv4 from the runners. Neither mirror can be trusted on its own, so retrying one of them harder cannot fix either failure mode.This keeps the in-region mirror as the first choice, and when an image exhausts its retries on an apt download failure it is rebuilt once against Canonical instead of reding the check. The mirror is already a
--build-arg, so the change is confined to the CI job: the publisheddocker/serveranddocker/keeperDockerfiles are untouched and still default to Canonical, as intended by 7cb4072.The second attempt is reached only through
APT_MIRROR_ERRORS, which are the signatures of a mirror not handing over a file. A broken package name, an unsatisfiable dependency or any other genuine packaging error produces none of them and still fails on the first attempt, so the retry allowlist narrowed in #108969 keeps its fail-fast property. Alpine images are unaffected:apkfailures do not print any of these strings.Measured over 180 days of CI, restricted to apt download failures in the
Docker server imageandDocker keeper imagechecks: 82 failed image builds across 12 bursty days. The nine since the in-region mirror was adopted are all arm64, that is, all onports.ubuntu.com.Validated by building the exact failing layer on an aarch64 host with the in-region mirror pointed at a region that does not resolve: the build fails twice against the dead mirror, is rebuilt against
ports.ubuntu.comand succeeds. Also checked that a genuine build error still fails on the first attempt with no second mirror tried, that a healthy build issues exactly one buildx invocation per architecture as before, and that without--apt-mirror-regionnothing changes. The package that 503'd,tzdata_2026c-0ubuntu0.22.04.1_all.deb, downloads fine from Canonical.Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/115726]
Version info
26.8.1.1913(included in26.8and later)