Skip to content

Skip the targeted job instead of failing it when the GitHub API fails during test selection - #126783

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:ci-skip-targeted-on-github-api-error
Oct 21, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:ci-skip-targeted-on-github-api-error

Conversation

@groeneai

@groeneai groeneai commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #76867

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

A targeted stateless or integration job now retries the GitHub API reads of its test selection for up to 3 minutes and is then skipped, not errored, when GitHub keeps answering with a server error, a network error, a rate limit, or a diff that is still being generated.

Description

The targeted jobs read the pull request, its diff and, on a rerun, the start of the attempt from the GitHub API with one requests.get each, without a retry. Any GitHub error ended the job ERROR before a test ran, which also skips the jobs that wait for it. Example, as reported in #76867 (comment): https://s3.amazonaws.com/clickhouse-test-reports/PRs/76867/4a5edeeaabdf6986907e20c646088d0c29f2227d/pr/stateless_tests_arm_asan_ubsan_targeted/job.log (500 Server Error from compare/<base>...<sha>). In the last 30 days CIDB has 6 such jobs on 5 PRs: compare 500 x3, pulls/<N> read timeout x2, pulls/<N> 403 rate limit x1. The same compare request for #76867 returns 200 now, so that one was transient.

A large diff fails differently: compare answers 422 The diff is taking too long to generate. and serves it to a later request (I measured 422, 422, then 200 for a 193 MB range).

The three reads now go through Targeting._github_get. It retries for 3 minutes (github_retry_sec, the same budget the CIDB reads got in review of #125613) on HTTP >= 500, on that 422, and on connection, timeout and chunked-encoding errors. A rate limit is not retried, because GitHub asks not to retry before the limit resets. If the read still fails, it raises GitHubUnavailableError, and both targeted jobs handle it like CIDBTimeoutError: SKIPPED, not cached, with a workflow warning and a comment. Other HTTP errors and the head-SHA check still end the job ERROR.

Validation, local: master vs this change with mocked requests.get and a fake clock (5xx, 422, network errors, rate limits, the rerun cutoff), and against the real GitHub API. On a 14-week compare range, GitHub answered 422 and 502 for 3 minutes, then the read raised GitHubUnavailableError. test_selection_smoke passes.


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

Version info

  • Merged into: 26.11.1.466-master (included in 26.11 and later)

The targeted stateless and integration jobs read the pull request, its
diff and, on a rerun, the start of the attempt from the GitHub API with
one bare `requests.get` each. A GitHub 5xx, a network error or a rate
limit raised out of the selection and ended the job `ERROR` before any
test ran, which also skips every job that waits for the core blocking
jobs (e.g. ClickHouse#76867: `500 Server Error` from `compare/<base>...<sha>`;
6 such jobs in 30 days in CIDB: compare 500 x3, `pulls/<N>` read
timeout x2, `pulls/<N>` 403 rate limit x1).

All three reads now go through `Targeting._github_get`, which retries
for `github_retry_sec` (180 s, the "retries up to 3 minutes, then skip"
policy of the CIDB reads) on HTTP >= 500, on `422 The diff is taking too
long to generate` (GitHub serves a large diff to a later request:
measured 422, 422, then 200 for a 193 MB range), and on connection,
timeout and chunked-encoding errors. A rate limit (429, or a 403 with
`x-ratelimit-remaining: 0` or "rate limit" in the body) is not retried,
as GitHub asks not to retry before the limit resets. When the reads keep
failing it raises `GitHubUnavailableError`, and both targeted jobs treat
it like `CIDBTimeoutError`: `SKIPPED`, not cached, with a workflow
warning and a comment. The strict wrapper of the previously failed tests
re-raises it, so the rerun cutoff read is not turned into a generic
`RuntimeError`. Any other HTTP error and the head-SHA guard still end
the job `ERROR`.

Related: ClickHouse#76867

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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; 2 findings) plus my own review (2 nits).

# Sev Finding Verdict Evidence / action
1 ⚠️ The last retry starts at the 3-minute deadline, so its 60 s timeout can stretch a read to about 4 minutes (_github_get) DISAGREE By design: 180 s is the retry window, and the request at the deadline is the retry the last backoff waited for. Measured: 190.6 s against the real API, then GitHubUnavailableError. Same outcome (SKIPPED); the extra 60 s at most is small against the 2.5 h job timeout.
2 ⚠️ No committed test proves the retry and skip behaviour DISAGREE Test-infrastructure changes ship no infrastructure tests (#119766). Validated locally instead: master vs this change on the same scripted responses (5xx, 422 "too long to generate" vs another 422, 404, permission 403, rate-limit 403/429, connection/read-timeout/chunked errors, the rerun cutoff). Master fails every retry/skip case; non-retryable cases and the head-SHA check behave as before. Both job handlers are the existing CIDB-timeout skip block with the new exception added to its except.
3 💡 An ast fuzzer targeted job (best effort) now retries up to 3 minutes per failing read before it falls back noted, not blocking Bounded, and a transient error now recovers instead of dropping those tests.
4 💡 test_selection.md: "A rate limit is not retried" could be read as the job failing noted, not blocking A rate limit skips the job at once, like an exhausted retry.

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

Session id: cron:clickhouse-review-slot-8:20261019-193700

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. A local harness runs master's and this PR's find_tests.py on the same scripted requests.Response sequences with a fake clock; master errors on every GitHub 5xx, 422 "too long to generate", network error and rate limit.
b Root cause explained? Each GitHub read (pulls/<N>, compare, rerun attempt) was one requests.get + raise_for_status() with no retry, and the targeted callers skip only on CIDBTimeoutError.
c Fix matches root cause? Yes. One retrying helper for the three reads, then a typed GitHubUnavailableError that the callers skip on. 404, a permission 403, other 422s and the head-SHA check still error.
d Test intent preserved / new tests added? CI infrastructure change, so no infrastructure test. Validated locally; test_selection_smoke passes.
e Both directions demonstrated? Yes. Master raises HTTPError/RuntimeError, this PR returns the diff after retries or raises GitHubUnavailableError after 3 minutes. Against the real API, a 14-week compare range got 422/502 for 3 minutes and then raised GitHubUnavailableError.
f Fix is general across code paths? All three GitHub reads, the strict previously-failed wrapper (rerun cutoff), and the stateless and integration targeted jobs. The AST fuzzer reads are best effort and still fall back.
g Fix generalizes across inputs (params/datatypes/wrappers)? 500/502, 422 (too long vs other), 404, 403 (permission vs rate limit), 429, connection, read timeout, chunked encoding, retry budget exhausted.
h Backward compatible? (maintainer-approved exception only) Yes. CI scripts only; the CIDB skip message and comment are unchanged.
i Invariants and contracts preserved? The head-SHA check is kept; the diff and the cutoff are cached only on success; a skipped job is not cached; the token is never logged.

Session id: cron:clickhouse-impl-slot-6:20261019-191400

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @fm4v, could you review this and add the can be tested label so CI runs? The three GitHub API reads of the targeted test selection now retry 5xx, the 422 "diff is taking too long to generate" and network errors for 3 minutes (the budget from #125613), then the job is skipped through a new GitHubUnavailableError, like CIDBTimeoutError, instead of ending ERROR.

@clickhouse-gh

clickhouse-gh Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2db0c5d]

Summary: ✅


AI Review

Summary

The PR retries transient GitHub API failures during targeted test selection and reports exhausted retries or rate limits as uncached SKIPPED results in both stateless and integration jobs. No actionable findings. Local validation passed all 19 selection smoke tests and 36 focused failure-path scenarios.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Oct 19, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 21, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Oct 21, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable.

@alexey-milovidov alexey-milovidov self-assigned this Oct 21, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 21, 2026
Merged via the queue into ClickHouse:master with commit 0991d28 Oct 21, 2026
178 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 21, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 25, 2026
…ough-previously-failed-lookup

Resolve the conflict in get_previously_failed_tests_with_info: the strict
lookup re-raises both CIDBTimeoutError (this PR) and GitHubUnavailableError
(ClickHouse#126783), so the targeted job skips when either CIDB or GitHub is unavailable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). 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