Skip to content

Anchor the apt mirror fallback on the sentence buildx actually prints - #116441

Closed
groeneai wants to merge 2 commits into
ClickHouse:masterfrom
groeneai:ci-anchor-buildx-solve-error
Closed

groeneai wants to merge 2 commits into
ClickHouse:masterfrom
groeneai:ci-anchor-buildx-solve-error

Conversation

@groeneai

@groeneai groeneai commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #115726

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):

...

Description

#115726 rebuilds a Docker image against Canonical when the in-region apt mirror
withholds a .deb. That rebuild has never been selected: its gate looks for
ERROR: failed to solve:, and buildx prints ERROR: failed to build: failed to solve:. terminal_build_failure fails closed to "" when the anchor is absent, so
is_apt_mirror_failure is unconditionally False and the mirror loop always breaks
after the first attempt.

Master today, sha 0f7cac9ea103e2101c7162fb6657bf5578ea2c77
(report):
six apt mirror 1/2, zero apt mirror 2/2, no exhausted its retries line. That job
log contains the code's spelling 0 times and buildx's 4 times.

Driving the predicate over every Docker%image% failure row of the year ending
2026-08-25 00:00 UTC (249 rows): the shipped anchor is True on 0, this one on
41, and each of those 41 carries an E: apt error inside the step the build
stopped on. The bare spelling never appeared in that year; all 145 solve errors use
the prefixed form.

I changed the literal and the docstring above it, which documented the same wrong
sentence. The fence and the E: severity narrowing #115726 added are both correct and
are kept: the earlier buffer-wide match would fire on 82 rows instead of 41, which is
the recovered W: Failed to fetch false positive that narrowing exists to prevent.

The fixture hard-coded the same wrong spelling, so the suite passed identically with
the classifier dead. Correcting it makes four of its arms fail against the old code.

Still out of scope: when a brownout withholds the package indexes, apt-get update
only warns and the build dies later with
E: Package 'busybox' has no installation candidate - indistinguishable from a genuine
packaging error, which the suite has an arm against, so no token list covers it. Some
rows of the current brownout are that shape.

Sweep over the year ending 2026-08-25 00:00 UTC
variant rows True (of 249)
shipped ERROR: failed to solve: 0
this PR failed to solve: 41
buffer-wide (pre-refinement form) 82
negative-control needle 0

Token census over the same rows: ERROR: failed to build: failed to solve: in 145,
ERROR: failed to solve: in 0, negative control 0. Both Docker image checks, all
arches, all three Dockerfiles.

The shorter literal is not laxer: on those 249 rows it selects a byte-identical
terminal block to the full sentence (145 identical, 104 both empty, 0 differing),
against a wrong-anchor control that differs on 145.


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


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

The Canonical rebuild added in ClickHouse#115726 has never been selected. Its gate looked
for "ERROR: failed to solve:", while buildx prints "ERROR: failed to build:
failed to solve:". terminal_build_failure fails closed to "" when the anchor is
absent, so is_apt_mirror_failure was unconditionally False, should_try_next_mirror
was reachable only through the timeout branch, and the mirror loop always broke
after the first attempt.

On master at 0f7cac9 the job log contains the
code's spelling 0 times and buildx's 4 times; six build legs printed
"apt mirror 1/2" and none printed "2/2".

Driving the predicate over every Docker image failure row of the last 365 days
(260 rows): the shipped anchor is True on 0 of them, this one on 48, and each of
those 48 carries an E: apt error inside the step the build stopped on. The bare
spelling has not appeared once in a year, while all 156 solve errors use the
prefixed form. Reverting to the pre-refinement buffer-wide match would fire on 93
rows, which is the recovered "W: Failed to fetch" false positive the fence and the
E: severity narrowing exist to prevent, so both are kept.

The fixture hard-coded the same wrong spelling, so the suite passed identically
with the classifier dead. Correcting it makes four of its arms fail against the
old code.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Aug 26, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (2 rounds, 0 blockers outstanding)

I review my own PRs with an independent model before opening them, and record every
finding with its verdict so a reviewer can see what was challenged and why.

Two rounds. Round 1 raised one issue in the source and it was fixed; round 2 raised
none.

# Finding Verdict
❌ The docstring of terminal_build_failure still documented ERROR: failed to solve: ..., the sentence this PR proves buildx never prints. Written by the same commit as the wrong literal, so only one of the two was being corrected. AGREE, fixed in aed36a2
⚠️ Countable figures in the description came from a window whose end fell inside the ongoing brownout, so re-running the sweep gave different numbers each time (264/52/97 -> 265/53/98 within minutes). AGREE, fixed: every figure is now from a settled window ending 2026-08-25 00:00 UTC, stable across repeated runs
⚠️ Same paragraph quoted a denominator ("4 of the 12 rows today") that kept growing as the brownout continued. AGREE, fixed: the limitation is stated without a moving figure
💡 The docstring quotes the full ERROR: failed to build: failed to solve: while the code anchors on the shorter failed to solve:. DISAGREE: on all 145 real rows carrying a terminal block the substring selects a byte-identical block to the full sentence (0 differing, wrong-anchor control differs on 145). Documenting what buildx prints and matching a substring of it is consistent
💡 An adversarial log shape - a terminal ERROR: failed to build: line that is indented - would defeat the line scan. DISAGREE: that indentation is produced only by Utils.print_formatted_error, which prints to stdout, while Result.info is read from the log file (result.py:920). It occurs 101 times in the rendered job log and 0 times across 272 real Result.info payloads. The shipped code is equally blind to it, so this PR does not introduce it
💡 Ship only the one-line source fix and drop the test change. DISAGREE: with the old fixture the source fix is invisible to its own suite. Reverting only the fixture spelling reddens exactly one arm, and that arm is the new premise assert, so it is a live drift guard

Also checked: the other two docker buildx call sites do not parse solve output, so
they need no equivalent change; no open PR addresses this (all 400 open PRs' file lists
read, one touches ci/jobs/docker_server.py and it is unrelated); master still carries
the wrong literal.

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Aug 26, 2026
@clickhouse-gh clickhouse-gh Bot closed this Aug 26, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [aed36a2]

Summary: ✅


AI Review

Summary

This PR fixes the terminal_build_failure anchor to match the docker buildx footer that the CI job actually sees and updates the fixture so the focused mirror-fallback tests exercise that live shape. I did not find a correctness, safety, or contract issue in the current diff; the shorter failed to solve: anchor still selects the terminal fenced block while preserving the existing fail-closed behavior when that shape is absent.

Missing context / blind spots
  • ⚠️ I could not run ci/tests/test_docker_apt_mirror_fallback.py end-to-end in this environment because /usr/bin/python3 does not have the pytest module installed. The code paths were instead validated with direct Python probes of terminal_build_failure, is_apt_mirror_failure, and the canned build_and_push_image driver from the test file.
Final Verdict

✅ No blocking issues found.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 26, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, not statistical. Two instruments. (1) The real master job log for 0f7cac9ea103e2101c7162fb6657bf5578ea2c77: the code's spelling occurs 0 times, buildx's 4 times (controls: buildx 30, a never-appearing needle 0); driving the shipped predicate over the arm64 leg gives terminal_build_failure length 0 and is_apt_mirror_failure False while 14 raw E:+mirror lines are present. Six legs printed apt mirror 1/2, none printed 2/2. (2) pytest ci/tests/test_docker_apt_mirror_fallback.py with the fixture corrected to buildx's real spelling.
b Root cause explained? BUILDX_SOLVE_ERROR was "ERROR: failed to solve:"; buildx prints ERROR: failed to build: failed to solve:. terminal_build_failure returns "" when the anchor is absent (fail-closed by design), so is_apt_mirror_failure iterates an empty string and is unconditionally False, should_try_next_mirror is reachable only via the timeout branch, and the mirror loop always breaks after attempt 1.
c Fix matches root cause? Yes. The defect is a transcription error in one literal and the fix is that literal, +1/-1. No widened bound, no defensive guard, no retry-count change. Function bodies, the fence half and the E: severity half are untouched, all three measured correct.
d Test intent preserved / new tests added? No arm removed or weakened. The fixture now matches real buildx output, which strengthens it: with the old fixture the suite passed identically against the dead classifier. One premise assert added, in the file's existing idiom.
e Both directions demonstrated? Yes, 5 isolated arms. Baseline 8 passed; code fix only 8 passed (the fix is invisible to the shipped suite, which is the finding); mutant needle 4 failed; fixture fix only, shipped code 4 failed (the liveness proof); both fixes 8 passed. On the real log: shipped length 0 / False, corrected length 3234 / True, never-appearing needle length 0 / False.
f Fix is general across code paths? grep -rn 'terminal_build_failure|BUILDX_SOLVE_ERROR' ci/ --include='*.py' returns only the definition, its one use and its one caller. Both Docker server image and Docker keeper image go through build_and_push_image, so one fix covers both, confirmed by accepting rows on both checks and all three Dockerfiles. Every other literal in the file audited against the 249 rows of the year ending 2026-08-25 00:00 UTC: the fence 145, E: 85, the two timeout strings 0 because they are strings the job emits itself, and the zero-hit BUILDX_RETRY_ERRORS members belong to a disjunctive list whose other members fire.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A for ClickHouse types (this is CI Python). Log-shape axis measured instead: all 145 solve-error lines across those 249 rows sit at column 0, as does the deciding line on all 41 accepted rows; the in-step #N ERROR: copy carries the needle in 0 rows. Boundary inputs (empty, whitespace, anchor with no fence, anchor with one fence, fence pair with no anchor) all decline. Adversarial ordering arms confirm the last attempt decides.
h Backward compatible? (maintainer-approved exception only) Yes, nothing user-visible. No setting, no SettingsChangesHistory.cpp entry, no serialization format, CI-internal only.
i Invariants and contracts preserved? Yes. The fail-closed contract holds: every unrecognized shape still yields "" / False. The "retries append, so the last attempt is terminal" semantics are unchanged. Only which anchor is sought changed, never that an unrecognized log declines. Verified by the same sweep: 41 of 249 rows accept and every one of them carries an E:+mirror token inside the terminal block, 0 exceptions.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @leshikus, could you review this? The Canonical apt-mirror fallback added in #115726 has never been selected: its gate looks for ERROR: failed to solve: while buildx prints ERROR: failed to build: failed to solve:, so terminal_build_failure fails closed and the mirror loop always breaks after the first attempt.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Master already carries this fix in a stronger form, so I have not merged master into this branch: the conflict is in the very block that was rewritten, and resolving it would revert the stronger version.

deaccc6c6a0d45881407d70faf247e864ae40abc (#116444, merged 2026-08-26 21:00Z) sets BUILDX_SOLVE_ERROR = "failed to solve:", byte-identical to the line this PR changes, and adds four things this PR does not have: is_buildx_solve_error, requiring the terminal error to start at column 0, so the per-step #12 ERROR: ... copy cannot stand in for it, where my change matches the substring anywhere on a line; the matched block ending at the closing fence instead of running on into the Dockerfile source that buildx echoes after it; BUILDX_STEP_HEADER_PREFIX, so the > header that repeats the RUN command gets no verdict; and the fail-closed path logged. Its fixture also pins both buildx wordings through SOLVE_ERROR_WORDINGS, where mine pinned only the current one.

Measured rather than read: the constants and both functions extracted verbatim from each tree and driven over the same real master job log this PR was built from (0f7cac9ea103, arm64 ubuntu leg). Master answers is_apt_mirror_failure = True with none of my code, and its terminal block is tighter than mine, 1769 against 3234 characters, because of the fence fix. Controls: master with the old wording restored gives False, the pre-fix refinement 3f7dd8331b8e gives False, an impossible needle gives False.

So there is nothing here worth reviewing, and nothing further is owed from me. Whether to close it is a maintainer's call; I am not touching it.

One limit is unchanged in both trees, for the record: when a 503 hits the index fetch, apt-get update fails non-fatally and the build dies later as E: Package '...' has no installation candidate, which no token list separates from a genuine packaging error.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Superseded by #116444 (deaccc6c6a0, merged 2026-08-26 21:00Z), which fixes the same
defect in the same two files in a stronger form, so I am closing this. The defect this PR
reports is real - I confirmed it rather than took it on the description.

Measured, not read: the constants and both functions extracted verbatim from three trees
and driven over a real-shaped docker buildx build --progress=plain failure tail whose
step withheld a .deb, in each of the two wordings buildx has used for its top-level
error.

tree buildx >= 0.23 wording buildx <= 0.22 wording
base 3a78f4b0bb5 (pre-fix) terminal block 0 chars, is_apt_mirror_failure False 642 chars, True
this PR, head aed36a2 659 chars, True 642 chars, True
master deaccc6c6a0 340 chars, True 340 chars, True

Row 1 is the dead fallback this PR set out to revive, so the diagnosis holds. Rows 2 and 3
both revive it; master's block is tighter because it ends at the closing fence instead of
running on into the Dockerfile source buildx echoes after it, which is recipe text, not
build output.

Four things master has that this PR does not:

  • BUILDX_ERROR_PREFIX - the terminal error has to start at column 0, so the per-step
    #12 ERROR: ... copy cannot stand in for it. This PR matches the substring anywhere on
    a line.
  • The matched block ends at the closing fence, not at the solve error.
  • BUILDX_STEP_HEADER_PREFIX, so the > header that repeats the RUN command gets no
    verdict.
  • The fail-closed path is logged, which is what kept this from being noticed.

BUILDX_SOLVE_ERROR = "failed to solve:" on master is byte-identical to the one line this
PR changes.

On the test side, master's suite passes 9 arms including
test_every_buildx_wording_of_the_top_level_error_is_read, which drives both wordings
through SOLVE_ERROR_WORDINGS; this branch passes 8 and pins only the current one. The
assertion added here hardcodes the new wording, but master's fix deliberately makes the
wording stop mattering - anchoring on the prefix plus failed to solve: - so pinning the
sentence back is a step away from that design rather than an addition to it.

Nothing here survives a merge with master, and the conflict is inside the very block
master rewrote, so resolving it either way reverts the stronger version. Thanks for the
sweep in the description - the year-long token census over the 249 Docker%image% failure
rows is what makes the "0 rows carried the old spelling" claim checkable, and it agrees
with the reading of the buildx changelog that #116444 went on.

The limitation you flagged is unchanged in both trees and worth keeping in mind: when a
503 hits the index fetch, apt-get update fails non-fatally and the build dies later as
E: Package '...' has no installation candidate, which no token list separates from a
genuine packaging error.

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-ci-master PR origin: master/nightly CI monitoring finding manual approve Manual approve required to run CI pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants