Skip to content

Retry docker buildx on transient docker.io registry errors - #108969

Merged
maxknv merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-docker-server-image-buildx-registry-retry
Jun 30, 2026
Merged

maxknv merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-docker-server-image-buildx-registry-retry

Conversation

@groeneai

@groeneai groeneai commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #105139
Related: #108675

Changelog category (leave one):

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

Description

The Docker server image job builds the distroless/alpine/ubuntu images with docker buildx build. buildx resolves the SBOM scanner image (docker/buildkit-syft-scanner, pulled because of --sbom=true) and the base images from docker.io. A transient docker.io outage fails the build at the resolve step, e.g.:

#2 resolve image config for docker-image://docker.io/docker/buildkit-syft-scanner:stable-1
#2 ERROR: unexpected status from HEAD request to https://registry-1.docker.io/...

and the downstream docker library image test then reports image does not exist! as a secondary victim.

praktika's Shell.run / Result.from_commands_run already support retries with exponential backoff plus an error allowlist, but the buildx build and the imagetools merge ran with no retries. This wires retries=5 and an allowlist of transient registry/network signatures into both calls. The allowlist keeps fail-fast behavior for genuine Dockerfile/build errors. Mirrors the existing retry hardening for in-Dockerfile wget downloads (#105139) and the keeper image S3 artifact fetch (#108675).

Observed on master and PRs during a ~6 min docker.io blip on 2026-06-30 15:00-15:06 UTC (recovered on its own). Report (master): https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=36f0c2d95475aafa597cacebace14f5888908dcd&name_0=MasterCI&name_1=Docker%20server%20image

Version info

  • Merged into: 26.7.1.307 (included in 26.7 and later)

The "Docker server image" job builds the distroless/alpine/ubuntu images with
`docker buildx build`. buildx resolves the SBOM scanner image
(docker/buildkit-syft-scanner, pulled because of --sbom=true) and base images
from docker.io. When docker.io has a transient outage, the build fails at:

  ClickHouse#2 resolve image config for docker-image://docker.io/docker/buildkit-syft-scanner:stable-1
  ClickHouse#2 ERROR: unexpected status from HEAD request to https://registry-1.docker.io/...

and the downstream "docker library image test" then reports "image does not
exist!" as a secondary victim.

praktika's Shell.run / Result.from_commands_run already support retries with
exponential backoff and an error allowlist, but the buildx build and the
imagetools merge commands ran with no retries. Wire retries=5 and an
allowlist of transient registry/network signatures into both. The allowlist
keeps fail-fast behavior for genuine Dockerfile/build errors. This mirrors the
existing retry hardening for the in-Dockerfile wget downloads (ClickHouse#105139) and the
keeper image S3 artifact fetch (ClickHouse#108675).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

groeneai commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes (for the failure class). buildx fails deterministically when docker.io returns a bad status resolving docker/buildkit-syft-scanner:stable-1; CIDB shows the exact signature unexpected status from HEAD request to https://registry-1.docker.io/... on master + 2 PRs in a 6 min window (2026-06-30 15:00-15:06 UTC). The transient itself is not reproducible on demand, which is precisely why retry is the correct remedy.
b Root cause explained? docker buildx build resolves the SBOM scanner image (pulled by --sbom=true, docker_server.py:234) and base images from docker.io. A docker.io HEAD-request failure aborts the build at the resolve step; the buildx call ran with no retries, so a momentary registry blip fails the whole job. The docker library image test ... image does not exist! lines are secondary victims of the aborted build.
c Fix matches root cause? Yes. Wires praktika's native retries/retry_errors (exponential backoff, fail-fast on non-matching errors) into the buildx build + imagetools-merge calls, so a transient registry error is retried instead of failing the job.
d Test intent preserved? / New tests added? N/A (CI harness change). No test assertions weakened; the allowlist preserves fail-fast for genuine Dockerfile/build errors.
e Demonstrated in both directions? The framework retry path (Shell.run utils.py:313-462) is exercised by existing praktika usage; this PR only supplies retries/retry_errors args. The fix cannot be locally driven against a real docker.io outage, but the allowlist + backoff behavior is the same accepted mechanism used in #105139 and #108675.
f Fix is general, not a narrow patch? Yes. Both buildx invocations in build_and_push_image (per-arch build and the push-time imagetools merge) get the retry, so every os/arch image build is covered, not just the one variant CI happened to catch.
g Fix generalizes across inputs? N/A (not a code-path/datatype bug). Per the AI review, the allowlist was narrowed to genuine registry/network failure signatures only: failed to do request, unexpected status from HEAD request, TLS handshake timeout, i/o timeout, connection reset by peer, connection refused. Progress-only/broad substrings (resolve image config, registry-1.docker.io, error from registry) were removed because they can appear in normal --progress=plain output and would have retried non-transient Dockerfile failures.
h Backward compatible? N/A. CI-only change; no settings, no on-disk/wire format, no user-visible behavior.
i Invariants and contracts preserved? Yes, and strengthened. praktika's retry scans every stderr line for any allowlist substring (utils.py:416). With the narrowed list (none of whose strings appear in normal progress output), a real RUN/COPY/package-install/Dockerfile error fails fast on the first attempt; only genuine transient registry/network errors are retried.

Session id: cron:clickhouse-worker-slot-7:20260630-203100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv — could you review this? It adds retries (praktika's native retries/retry_errors with backoff + fail-fast) to the docker buildx build and imagetools-merge calls in the Docker server image job, so a transient docker.io registry blip (seen 2026-06-30 resolving buildkit-syft-scanner) is retried instead of failing the whole job.

@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f0de148]

Summary: ✅


AI Review

Summary

This PR adds retry handling for transient registry/network failures around the docker buildx build and docker buildx imagetools create calls in the Docker image CI job. The previous retry-filter issue has been fixed by removing progress-only and overly broad tokens, and I did not find any remaining correctness or CI-contract findings in the current diff.

Final Verdict

Status: ✅ Approve

Minimum required actions: none.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 30, 2026
Comment thread ci/jobs/docker_server.py Resolved
AI review on ClickHouse#108969 flagged that BUILDX_RETRY_ERRORS matched progress-only
text. buildx emits "resolve image config for docker-image://..." as normal
--progress=plain output (--sbom/--provenance pull the syft scanner and base
images on every build), and praktika's retry scans every stderr line for any
substring. So a later RUN/COPY/package-install/Dockerfile failure that runs
after that progress line was retried 5x even though its error was not transient.

Drop the progress-only and broad substrings ("resolve image config",
"registry-1.docker.io", "error from registry") and keep only actual
registry/network failure signatures: "failed to do request", "unexpected
status from HEAD request" (the motivating docker.io HEAD-500 outage),
"TLS handshake timeout", "i/o timeout", "connection reset by peer",
"connection refused". None of these appear in normal progress output, so
genuine Dockerfile/build errors fail fast on the first attempt.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jun 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Narrowed BUILDX_RETRY_ERRORS to genuine registry/network failure signatures only (f0de148): failed to do request, unexpected status from HEAD request, TLS handshake timeout, i/o timeout, connection reset by peer, connection refused.

Removed the progress-only/broad substrings: resolve image config (emitted as normal --progress=plain output by the --sbom/--provenance scanner and base-image resolution), registry-1.docker.io (bare host, matches permanent not found/unauthorized too), and error from registry (matches permanent manifest/auth errors). praktika scans every stderr line for any allowlist substring (utils.py:416), so a later RUN/COPY/package-install/Dockerfile failure that ran after one of those progress lines is now no longer retried. None of the kept signatures appear in normal progress output, so real build errors fail fast on the first attempt. The motivating outage signature (unexpected status from HEAD request to https://registry-1.docker.io/...) is retained.

@maxknv
maxknv enabled auto-merge June 30, 2026 20:49
@maxknv
maxknv self-requested a review June 30, 2026 20:49
@maxknv
maxknv added this pull request to the merge queue Jun 30, 2026
Merged via the queue into ClickHouse:master with commit 1a00098 Jun 30, 2026
174 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 30, 2026
pull Bot pushed a commit to sonvt1710/ClickHouse that referenced this pull request Sep 5, 2026
The two signatures added in ClickHouse#118213
were justified by what the base image contains: on a pristine `ubuntu:22.04`, a
package Ubuntu ships that has no installation candidate or unmet dependencies can
only be resolving against a partial index. That inference holds, but it does not
cover the third shape apt produces. Which of the three it picks depends only on
what the missing suites were providing: `busybox`, `ca-certificates` and `locales`
come out as `has no installation candidate` because `/var/lib/dpkg/status` still
names them, a `wget` whose `libpsl5` has gone comes out as `Unable to correct
problems, you have held broken packages`, and `wget` and `tzdata` with nothing left
to refer to them come out as the one shape that was missing, `Unable to locate
package`. Two of the ten image builds that reded on 2026-09-05 after 05:00 UTC were
that third shape, so they still did not reach Canonical.

`Unable to locate package` is also, unlike the other two, exactly what a misspelled
package name in one of these Dockerfiles produces, so adding it to
`APT_MIRROR_ERRORS` would have cost the fail-fast property that the narrowed retry
allowlist of ClickHouse#108969 exists to keep.

There is no need to infer any of this. `apt-get update` says so itself, in the very
same step: `W: Some index files failed to download`, printed once it has warned
about each suite the mirror withheld. Against a healthy mirror it refreshes every
suite silently, so that line is the mirror's own signature, and a genuine packaging
error - whose `apt-get update` was clean - carries none of it. `is_apt_index_failure`
requires both halves, and both from the step the build stopped on: the resolution
error inside the terminal fenced block, and the warning among the same step's
`#N `-prefixed output above it, which is the only thing tying the two together once
buildx has fenced the tail. All three shapes then move behind that evidence, so this
commit widens the coverage and narrows the licence at the same time.

Verified with a throwaway test against the real logs of all twelve failed builds
from CIDB: master says yes for ten of them and this commit for all twelve. Eight
negative cases still say no - a misspelled package in each of the three shapes, an
index warning belonging to an earlier successful step, the signature only in the
fenced step header, a truncated log with no terminal block, a non-apt failure, and
a recovered warning followed by a genuine `dpkg` error in the same step.

Example failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=dab9efce85ab16d6811013d2e2d03ad8245f398f&name_0=MasterCI&name_1=Docker%20server%20image
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
AI review on ClickHouse#108969 flagged that BUILDX_RETRY_ERRORS matched progress-only
text. buildx emits "resolve image config for docker-image://..." as normal
--progress=plain output (--sbom/--provenance pull the syft scanner and base
images on every build), and praktika's retry scans every stderr line for any
substring. So a later RUN/COPY/package-install/Dockerfile failure that runs
after that progress line was retried 5x even though its error was not transient.

Drop the progress-only and broad substrings ("resolve image config",
"registry-1.docker.io", "error from registry") and keep only actual
registry/network failure signatures: "failed to do request", "unexpected
status from HEAD request" (the motivating docker.io HEAD-500 outage),
"TLS handshake timeout", "i/o timeout", "connection reset by peer",
"connection refused". None of these appear in normal progress output, so
genuine Dockerfile/build errors fail fast on the first attempt.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…image-buildx-registry-retry

Retry docker buildx on transient docker.io registry errors
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 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.

4 participants