Skip to content

Retry docker buildx on a registry status failure regardless of the request method - #117301

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/retry-buildx-registry-status-any-method
Sep 3, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/retry-buildx-registry-status-any-method

Conversation

@groeneai

@groeneai groeneai commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

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

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

Retry docker buildx when the registry answers with a non-2xx status for any request method, not only HEAD.

Description

Docker keeper image failed resolving alpine:latest and ubuntu:22.04 from Docker Hub with httpReadSeeker: failed open: unexpected status from GET request to ...: 400 Bad Request. The retry did not fire: No retryable errors found, stopping retries, command failed after 1/2 attempt(s).

BUILDX_RETRY_ERRORS carried unexpected status from HEAD request, and its status-code entries are 429/5xx only, so nothing matched a 400 on a GET. The method is an interpolated field of one containerd format string, unexpected status from %s request to %s: %s, so pinning it covered only the method observed then. I replace it with the method-agnostic prefix, a strict superset of the entry it replaces, so nothing retried today stops being retried.

A second attempt would have worked: the failing leg died at metadata resolution after 951 s, while head-alpine-arm64, same platform and base images, resolved both fresh 9 s later.

Trade-off: the token also accepts a permanent 4xx. That is bounded by BUILDX_RETRIES = 2, is already the status quo for HEAD, and buildx_timeout already divides the job budget by 2 attempts. Allowlisting "transient" status codes is unsound here, since the observed 400 was itself transient.

Footprint over 45 days: 6 job runs across both docker image jobs and three workflows, none on master. The Failed to fetch apt-mirror class is a different, already-handled signature.

Validation: replaying the captured stderr through Shell.run reproduces the CI lines byte-for-byte, and reaches 2/2 attempt(s) with the change; changing only GET to HEAD makes master's own list retry it. Permanent failures still fail fast.

ci/praktika/docker.py holds separate, deliberately narrower retry lists for other jobs; none matches this error, and CIDB shows no occurrence of it there. Its merge_manifest has no retries at all.

No related open issue found.

Related: #114975 (comment)
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114975&sha=42581e0c27fdd48645f31bdb01747e2c06d8d98b&name_0=PR&name_1=Docker%20keeper%20image


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

…quest method

`Docker keeper image` failed resolving its two base images from Docker Hub with
`httpReadSeeker: failed open: unexpected status from GET request to ...: 400 Bad
Request`, and the retry did not fire: `No retryable errors found, stopping
retries`, `command failed after 1/2 attempt(s)`.

`BUILDX_RETRY_ERRORS` carried `unexpected status from HEAD request`, and its
status-code entries are 429/5xx only, so nothing matched a 400 on a GET. The
method is an interpolated field of a single containerd format string,
`unexpected status from %s request to %s: %s`, so the entry only ever covered
whichever method happened to be observed when it was written. Dropping the
method from the token makes it a strict superset of the entry it replaces: the
removed string contains the new one as a prefix, so every stderr line retried
before is still retried.

A second attempt would have worked. The failing leg died at metadata resolution
after 951 s, while `head-alpine-arm64`, same platform and same two base images,
resolved both fresh in 0.6 s each only 9 s later. So this was one invocation
stuck on one poisoned request pair, and the 400 was transient, which is also why
a status-code allowlist is unsound for this failure mode.

The token accepts a permanent 4xx too. That is bounded by `BUILDX_RETRIES = 2`,
it is already the status quo for HEAD, and `buildx_timeout` already divides the
remaining job budget by 2 attempts, so a second attempt consumes budget the model
already reserves. Neither the attempt count nor the timeout divisor changes here.

Validated by replaying the captured stderr through `Shell.run`: master's list
matches 0 of its 17 runtime tokens and stops at 1/2 attempts, byte-identical to
the CI log, while the new token matches 3 lines and reaches 2/2. Changing only
GET to HEAD in that same capture makes master's own unmodified list retry it,
which isolates the request method as the whole defect. Genuine permanent buildx
failures, including a live capture, still fail fast on the first attempt.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114975&sha=42581e0c27fdd48645f31bdb01747e2c06d8d98b&name_0=PR&name_1=Docker%20keeper%20image
PR: ClickHouse#114975
Related: ClickHouse#114975 (comment)

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Aug 31, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold
review of the resulting code, run first and without the author's evidence. One full pass, no
fix round needed. Nothing below changed the diff: all four items are in the pull request text.

# Sev Finding Verdict Evidence / action
1 ⚠️ The description claimed the ci/praktika/docker.py retry lists "share this wording". Neither list carries the token: _IMAGE_PULL_RETRY_ERRORS (:10-21) is transport-phrases only with no HTTP-status phrase, and the Docker.build list (:111-113) holds one entry, Error response from daemon: manifest unknown. AGREE, fixed before publication Rewrote it to what I could verify: those lists are separate and deliberately narrower, none matches this error, and CI DB shows no occurrence of it on their jobs.
2 💡 The validation note cited #115650 alone for the removal of ci/tests/. git log --diff-filter=D -- ci/tests shows two deleting commits. AGREE, fixed before publication Now cites #115650 and #117138, both merged 2026-08-30. The load-bearing fact is confirmed directly: git cat-file -t origin/master:ci/tests reports the path does not exist.
3 💡 The description omitted that the neighbouring merge_manifest (ci/praktika/docker.py:156-160) has no retries at all. AGREE, fixed before publication Disclosed in one clause. Deliberately not raised as separate work.
4 💡 The new comment says the method is "not part of the failure"; the method is part of the message text, and the intended claim is that it does not identify the failure. AGREE, not blocking Left as written. It justifies a non-obvious property of the upstream format string and reads correctly in context, so I did not churn the diff for it.

I re-derived the load-bearing claims independently rather than accepting them. Reconstructing
the 17-entry runtime list from both revisions (the literal plus the two sentinels appended
later in the file) and matching it against the six stderr fixtures: the captured failure
matches 0 tokens before and 1 token on 3 lines after; the same capture with only GET changed
to HEAD already retries on master's unmodified list; all three genuine permanent failures
still stop at the first attempt on both revisions. The set difference between the two lists is
exactly one entry, and the removed string has the new one as a prefix. From ci/praktika/job.py
the job cap is 18000 s and 1043 s were spent at the point of failure, so the second attempt
would have received the full 2700 s bound against a healthy resolve of 0.5 to 2.5 s.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-10:20260831-083300

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Replaying the captured job stderr through the real Shell.run retry loop prints No retryable errors found, stopping retries and command failed after 1/2 attempt(s), byte-identical to the CI log at 42581e0c27fdd48645f31bdb01747e2c06d8d98b. Pure string matching: no docker, no network, no timing.
b Root cause explained? Yes. Shell.run retries only when an entry of retry_errors is a substring of a stderr line, else it breaks after attempt 1. BUILDX_RETRY_ERRORS carried unexpected status from HEAD request and 429/5xx codes only, so the GET spelling of the same containerd error with a 400 matched nothing. The method is an interpolated field of unexpected status from %s request to %s: %s, so it was never part of the failure.
c Fix matches root cause? Yes. The defect is in the matcher, so the matcher is what changes: the interpolated method is dropped from the token. BUILDX_RETRIES is untouched at 2 and the timeout divisor is untouched, so no budget or scheduling behaviour moves.
d Test intent preserved / new tests added? Preserved. No test is weakened, and none is added: ci/tests/ no longer exists on master (removed by #115650 and #117138, both merged 2026-08-30), and the validation for this class of change is an uncommitted throwaway harness plus stderr fixtures, including the verbatim failing output and two real buildx captures.
e Both directions demonstrated? Yes, on the real captured failure. Before: 0 of 17 runtime tokens match, 1/2 attempt(s). After: 1 token matches 3 lines, Retryable error found, retry 1/2, Retrying in 2s, 2/2 attempt(s), so the second attempt actually ran.
f Fix is general across code paths? Yes. grep -rn "unexpected status from" --include=*.py returns only the edited site. That constant is read by both Result.from_commands_run call sites (docker buildx build and docker buildx imagetools create), and main dispatches the same script for both Docker server image and Docker keeper image, so one edit covers both jobs and both invocations. The separate retry lists in ci/praktika/docker.py and ci/praktika/gh_auth.py do not contain this token, belong to other jobs, and document deliberately narrower contracts, so they are left unchanged.
g Fix generalizes across inputs? Yes. The input space is stderr text, not types, so there is no Nullable/LowCardinality/Array axis. Six fixtures cover it: the real failure, the same failure in the HEAD spelling, two genuine permanent buildx failures (one captured live this session), a genuine apt-get build error, and the push-path 400. Every arm matched its predicted verdict.
h Backward compatible? Yes, trivially. No product code, no serialization, no settings, so no SettingsChangesHistory.cpp entry. The new token contains the removed one as a prefix, so it is a strict superset: every stderr line retried before is still retried, proven from the strings themselves and confirmed end-to-end by the HEAD-spelling fixture.
i Invariants and contracts preserved? Yes. The list's stated contract is to retry only genuine registry, network or mirror failures while a real Dockerfile or package error still fails fast on the first attempt. All three genuine-failure fixtures still stop at 1/2. The attempt bound is unchanged at 2, and buildx_timeout already divides the remaining job budget by 2 attempts, so a second attempt consumes budget the model already reserves. APT_MIRROR_ERRORS, terminal_build_failure and should_try_next_mirror are untouched and are consulted only after retries are exhausted.

Mutation battery, each required to redden the fixed arm: reverting the token and typo-ing the token both restore No retryable errors found at 1/2. Dropping the trailing space still matches, so the space is precision rather than correctness and no claim rests on it. Each mutant was diffed against the source first, so a non-applied mutation could not score as a pass.

ruff check --output-format=concise --quiet (exactly what ci/jobs/check_style.py runs, on the pinned 0.15.13) returns empty output.

Session id: cron:clickhouse-impl-slot-5:20260831-074502

@clickhouse-gh

clickhouse-gh Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6c0c91c]

Summary: ✅


AI Review

Summary

This PR broadens BUILDX_RETRY_ERRORS in ci/jobs/docker_server.py so the Shell.run stderr matcher retries the containerd unexpected status from <method> request ... registry failure regardless of whether buildx reported it on HEAD or GET. I reviewed the changed code, the shared retry logic, the existing PR discussion, and the cited Docker keeper image CI report, and I do not see a remaining correctness or rollout issue in the current diff.

Final Verdict

✅ No new inline findings.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this? BUILDX_RETRY_ERRORS pinned the request method in unexpected status from HEAD request, but that phrase comes from a single containerd format string in which the method is an interpolated field, so a registry blob fetch failing on a GET matched nothing and Docker keeper image gave up after one attempt. Dropping the method makes the token a strict superset of the entry it replaces.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 31, 2026
@alexey-milovidov alexey-milovidov self-assigned this Sep 3, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 3, 2026
Merged via the queue into ClickHouse:master with commit c9e1252 Sep 3, 2026
174 of 175 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 3, 2026
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 groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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