Skip to content

Retry a job image pull that failed DNS resolution - #115555

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/retry-job-image-pull-dns-servfail
Aug 21, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/retry-job-image-pull-dns-servfail

Conversation

@groeneai

@groeneai groeneai commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #113611

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 the praktika job's Docker image pull when the registry proxy's name fails to resolve, so a transient DNS failure no longer kills the whole job before any test runs.

Description

The retried job image pull added in #113611 declines to retry a DNS resolution failure, so the job aborts with zero tests run. From a failing job's log:

Run command: [timeout --verbose 300 docker pull clickhouse/stateless-test:...]
failed to copy: ... dial tcp: lookup
    dockerhub-proxy.dockerhub-proxy-zone on 127.0.0.53:53: server misbehaving
Retry 1/3: command failed, exit code: 1
No retryable errors found, stopping retries
ERROR: command failed after 1/3 attempt(s), exit code: 1

Root cause. _IMAGE_PULL_RETRY_ERRORS allowlists transport-class phrases. Go's resolver renders a SERVFAIL as server misbehaving, absent from that list, so a transient DNS blip takes the break path meant for permanent errors and the pull's non-fatal failure falls through to the implicit docker run pull, which has no retry wrapper.

The change adds that one phrase: a nameserver was reached and answered badly, so the same name can resolve on a later attempt.

no such host is deliberately not added: that is NXDOMAIN, i.e. permanent, so a misnamed image host would burn all three attempts instead of failing fast, and it has 0 occurrences in 90 days. A broader substring (dial tcp, lookup ) was rejected for the same reason, since both prefix NXDOMAIN too. A new arm pins that the NXDOMAIN line is still not retried.

Breadth. 4 jobs across 4 pull requests in 30 days, 0 on master, each carrying this phrase in the pull's own stderr. Each produced 0 test rows while sibling jobs on the same commit produced 55 to 950, so a whole check is lost, not one test.

Validation. The suite drives the real Shell.run loop, so its arms exercise the production matcher. Without the fix the new arms report 1 attempt instead of 3; with it, 25 passed, identical over 30 runs.

No related open issue found.

New test arms and their controls

The new arm feeds the verbatim production line rather than a bare phrase, because there the phrase is the tail of a nested resolver error inside a URL. It carries its own negative control: the same line matched against the allowlist with the entry removed must stop after one attempt. Without that control the arm could not distinguish this entry working from some other entry already matching, which is what the pre-fix job disproved by stopping after attempt 1.

Note also that the two errors in the log above differ, which is why the gap looks covered: the retried attempt got server misbehaving, the later docker run got the allowlisted connection refused, by which point no retry wrapper is in play. Only the second reaches the CI database, so the pull's own error appears only in the job log.

Arm Pre-fix Post-fix
test_each_transport_phrase_is_retried[server misbehaving] 1 attempt (red) 3 attempts
test_the_production_dns_failure_is_retried 1 attempt (red) 3 attempts, on_retry reports the phrase
its in-arm control (entry removed) 1 attempt 1 attempt
test_the_permanent_resolver_failure_is_not_retried (no such host) 1 attempt 1 attempt
test_permanent_error_is_not_retried, test_named_permanent_errors_are_not_retried green green

Deleting the entry reddens exactly the 2 arms that pin it and no others; widening it to dial tcp reddens the NXDOMAIN arm, so that arm is load-bearing rather than decorative.


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

The retried job image pull added in ClickHouse#113611 declined to retry a DNS
resolution failure, because the phrase Go's resolver emits for a SERVFAIL
was not in `_IMAGE_PULL_RETRY_ERRORS`. The pull stopped after one attempt,
its non-fatal failure fell through to the implicit `docker run` pull, which
has no retry wrapper, and the whole job aborted with zero tests run.

Verbatim from a failing job's own log:

    Run command: [timeout --verbose 300 docker pull clickhouse/stateless-test:...]
    failed to copy: httpReadSeeker: failed open: failed to do request: Get
        ".../blobs/sha256:180a6c67...": dial tcp: lookup
        dockerhub-proxy.dockerhub-proxy-zone on 127.0.0.53:53: server misbehaving
    Retry 1/3: command failed, exit code: 1
    No retryable errors found, stopping retries
    ERROR: command failed after 1/3 attempt(s), exit code: 1

Measured over 30 days: 4 jobs across 4 pull requests, none on master, and
every one of the four carries this phrase in the pull's own stderr. Each
produced zero test rows while sibling jobs on the same commit produced 55
to 950, so a whole check is forfeited rather than a single test.

`server misbehaving` means a nameserver was reached and answered badly, so
the same name can resolve on a later attempt. Its NXDOMAIN sibling `no such
host` is not added: that verdict is permanent, so a misnamed image host
would burn all three attempts instead of failing fast. It also has zero
occurrences in 90 days. Matching a broader substring such as `dial tcp` or
`lookup ` was rejected for the same reason, since both prefix NXDOMAIN too.

The two errors in that log differ, which is what makes the gap look already
covered: the retried attempt got `server misbehaving` while the later
`docker run` got `connection refused`, which is in the allowlist but by
then no retry wrapper is in play. Only the second error reaches the CI
database, so the pull's own error is visible only in the job log.

Tests: the new phrase joins the parametrized arm that pins every transport
entry as load-bearing, and a new arm feeds the verbatim production line
rather than a bare phrase, since there the phrase is the tail of a nested
resolver error inside a URL. That arm carries its own control, the same
line against the allowlist with the entry removed, which must stop after
one attempt; without it the arm could not distinguish this entry working
from some other entry matching. A further arm pins that the NXDOMAIN line
is still not retried, which fails if the entry is ever widened.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Aug 20, 2026
@groeneai

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

An independent model reviewed this diff cold against the code and the frozen PR body, and I
reviewed it separately before reading the author's evidence. Findings and how each was resolved:

# Finding Verdict
💡 The Related: link sat inside the template's leading HTML comment, so it would not render. Agreed, fixed. A visible Related: line was added outside the comment block.
💡 That visible line used the abbreviated #113611 where the template asks for full GitHub URLs. Agreed, fixed. It is now the full URL.
💡 The description ran one word over the internal 300-word budget. Agreed, condensed to 295 without cutting the job.log excerpt, which is the primary evidence that the pull declined to retry.
⚠️ I asked whether "all 4 carrying this phrase" blurs the in-cluster proxy name with registry-1.docker.io. Disagreed after measuring: two of the four resolve each hostname, and every one of the four prints the phrase on the pull's own stderr, which is what the sentence claims.

No blocker or major finding in either review. The final gate ran clean on the frozen body.

Two things I verified independently rather than taking from the author, because both are load
bearing in the description:

  • Breadth. The CI database returns 4 zero-test-row job errors in 30 days, on pull requests
    99495, 108650, 114846 and 108786, none on master or a release branch. The database records only
    the second error for three of them, so I fetched all four job.log files and confirmed each
    prints server misbehaving on the pull's own stderr, followed by
    No retryable errors found, stopping retries and command failed after 1/3 attempt(s).
  • no such host has 0 occurrences in 90 days, which is why it stays out of the allowlist.

The new arms are not decorative. Deleting the entry reddens exactly the two arms that pin it, on
the attempt count rather than on a guard; widening it to dial tcp reddens the arm that pins the
NXDOMAIN line still failing on attempt 1.

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

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes: python3 -m pytest ci/tests/test_job_image_pull_retry.py -q. On the pre-fix tree the two new arms report 1 attempt where 3 are required, every run. The production failure is deterministic in the same sense: the phrase either is in the allowlist or it is not, and all 4 sighted jobs took the same one-attempt path.
b Root cause explained? Shell.run retries only when some allowlist entry is a substring of a collected stderr line; otherwise it prints No retryable errors found, stopping retries and breaks. Go's resolver renders a SERVFAIL as server misbehaving, which _IMAGE_PULL_RETRY_ERRORS does not carry, so a transient DNS failure took the break path meant for permanent errors. The pull's non-fatal failure then fell through to the implicit docker run pull, which has no retry wrapper, and the job aborted with 0 test rows.
c Fix matches root cause? Yes. The cause is one missing transport-class phrase in the list the matcher reads, and the fix adds exactly that phrase to that list. No limit, timeout or threshold is changed, and no call site is touched: the retry policy stays in the shared wrapper.
d Test intent preserved / new tests added? Nothing existing is weakened. Three additions: the phrase joins the parametrized arm that pins every transport entry as load-bearing; a new arm feeds the verbatim production line; a new arm pins that the NXDOMAIN sibling no such host is still not retried. The two permanent-error arms are untouched and green throughout.
e Both directions demonstrated? Yes, both measured. Pre-fix, on master's runner.py verbatim with only the new tests applied: the 2 new arms fail (_attempts == 1, expected 3), 23 pass. Post-fix: 25 passed, and 30 consecutive runs were identical with 0 non-clean.
f Fix is general across code paths? The allowlist is read at exactly one site (runner.py:503). Every sibling retry carrier was read at master and dispositioned: prefetch-integration-test-images uses the inverse policy (retries any failure, single no matching manifest early return), so DNS is already retried there; BUILDX_RETRY_ERRORS already carries failed to do request, which prefixes this line; _GH_AUTH_RETRY_ERRORS and the docker.py inline list are different subsystems that do not pull job images.
g Fix generalizes across inputs? Yes for the input space this code has, which is error text rather than data types. Matched: the bare phrase (parametrized arm) and the verbatim nested form where the phrase is the tail of a resolver error inside a URL (new arm). Pinned as still NOT matched: the NXDOMAIN line, five permanent errors, and six pull-progress lines. The stderr/stdout split is pinned by the existing stdout arm.
h Backward compatible? Yes, with nothing to migrate. CI harness only: no user-visible surface, no setting, no serialization format, no SettingsChangesHistory implication. The only behaviour change is that one further error class now gets 3 attempts rather than 1.
i Invariants and contracts preserved? The list's stated invariant is transport-class phrases only, never a permanent failure. server misbehaving is a complete resolver verdict for a reachable but badly answering nameserver, and it matches none of pull access denied, manifest unknown, no matching manifest, invalid reference format, unauthorized, nor any progress line. The on_retry contract is unchanged and asserted: the hook fires once per retry actually issued and never for a permanent error.

Mutation coverage, measured on a disposable copy: deleting the entry reddens exactly the 2 arms that pin it and no others, failing on the attempt count (1 == 3) rather than on a guard; widening it to dial tcp reddens the NXDOMAIN arm. So neither new arm is vacuous.

Session id: cron:clickhouse-impl-slot-6:20260820-043600

@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0577039]

Summary: ✅


AI Review

Summary

This PR adds Go's server misbehaving DNS SERVFAIL wording to the job-image-pull retry allowlist and adds focused regression tests that pin both the new transient case and the permanent no such host case. I found no blocker or major issues in the submitted head: the retry scope remains narrow, the negative controls make the new tests load-bearing, and the PR metadata matches a CI Fix or Improvement.

Missing context / blind spots
  • ⚠️ I could not rerun python3 -m pytest ci/tests/test_job_image_pull_retry.py -q locally because /usr/bin/python3 in this environment does not have pytest; the review therefore relies on static inspection plus the PR's all-green CI.
Final Verdict

✅ No blocking or major issues found.

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

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this? It is a one-phrase follow-up to #113611, which you approved: the pull retry it added declines a DNS SERVFAIL, because Go's resolver renders that as server misbehaving and the phrase is not in _IMAGE_PULL_RETRY_ERRORS, so 2 of the 3 attempts are forfeited and the job aborts with zero tests run. no such host is deliberately left out since NXDOMAIN is permanent.

@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 05770396d with master 90a20ccf8 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 2101f9b08; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 703.89 MiB 700.85 MiB -3.04 MiB (-0.43%)

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 units

6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline.

Job report

@alexey-milovidov alexey-milovidov self-assigned this Aug 21, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 21, 2026
Merged via the queue into ClickHouse:master with commit 4007336 Aug 21, 2026
356 of 358 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 Aug 21, 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-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect 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.

3 participants