Skip to content

Retry gh auth token validation on transient GitHub API errors - #110769

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-praktika-gh-auth-retry-503
Jul 17, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-praktika-gh-auth-retry-503

Conversation

@groeneai

@groeneai groeneai commented Jul 17, 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):

...

Description

praktika's GH-auth pre-step runs gh auth login --with-token, which validates the token against api.github.com. A single transient GitHub API 5xx there (e.g. HTTP 503 Service Unavailable) hard-failed the entire job with GH auth failed - required by job.

Observed on a 40+ min LLVM Coverage job (PR #110674, commit fd47e5f):

WARNING: GH auth failed: command failed, exit code 1,
error validating token: HTTP 503: 503 Service Unavailable (https://api.github.com/)
ERROR: GH auth failed - required by job

This retries the token-validation call up to 4 times with exponential backoff, but only on transport-class errors (5xx / 429 / timeouts / connection resets). Non-transient auth errors (e.g. HTTP 401 Bad credentials) stay fatal and fail fast. It reuses the existing Shell.check retries/retry_errors mechanism, mirroring the docker buildx (BUILDX_RETRY_ERRORS) and wget retry patterns already in the repo.

Verified with a fake gh emitting the exact 503 line: without retry a single 503 hard-fails; with the fix it survives 2 transient 503s and succeeds on the 3rd attempt; a non-transient 401 still fails fast after 1 attempt (no wasted retries).

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110674&sha=fd47e5fd4a17fd5d2e8718015c62a288d297fb33&name_0=PR&name_1=LLVM%20Coverage

Version info

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

praktika's GH-auth pre-step runs `gh auth login --with-token`, which
validates the token against api.github.com. A single transient 5xx there
(e.g. HTTP 503 Service Unavailable) hard-failed the whole job with
"GH auth failed - required by job" (seen on a 40+ min LLVM Coverage job).

Retry the token-validation call up to 4 times with exponential backoff,
but only on transport-class errors (5xx/429/timeouts/connection resets).
Non-transient auth errors (e.g. HTTP 401 bad credentials) stay fatal and
fail fast. Reuses the existing Shell.check retries/retry_errors mechanism,
mirroring the docker buildx and wget retry patterns already in the repo.

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

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Fake gh emitting the exact error validating token: HTTP 503: 503 Service Unavailable line, driven through Shell.check: with retries=1 (old behavior) a single 503 hard-fails after 1 attempt.
b Root cause explained? GHAuth.auth/auth_from_settings call Shell.check("gh auth login --with-token", strict=True) with the default retries=1. gh validates the token against api.github.com; a transient GitHub API 5xx propagates as a non-zero exit, strict=True raises, and runner.py's _GH_Auth() returns False -> GH auth failed - required by job kills the job.
c Fix matches root cause? Yes. Adds bounded retry (retries=4, exponential backoff) to exactly those two gh auth login --with-token calls, gated on transport-class errors only.
d Test intent preserved / new tests added? N/A infra fix. Behavior unchanged on success and on non-transient auth failure; only transient 5xx/timeout/reset now retries.
e Both directions demonstrated? Yes. Old (retries=1): 1x 503 -> RAISES. New (retries=4, 503 list): 2x 503 -> SUCCEEDS on attempt 3. Non-transient HTTP 401 -> RAISES after 1 attempt (fails fast).
f Fix is general across code paths? Yes. Both gh auth login --with-token call sites (lambda-token path and JWT/PEM auth path) get the same retry list; no other GH-auth invocation validates a token.
g Fix generalizes across inputs? Retry list covers 500/502/503/504/429 + timeouts/connection resets/EOF; substring-matched against stderr. Auth-class errors (401 bad token) are intentionally excluded so they stay fatal.
h Backward compatible? Yes. No behavior change on success or on non-transient failure; only adds retries on transient transport errors.
i Invariants and contracts preserved? Yes. Shell.check retries/retry_errors is the existing, in-tree retry mechanism (same as docker_server.py BUILDX_RETRY_ERRORS); strict=True still raises after the final attempt, preserving the caller contract.

Session id: cron:clickhouse-worker-slot-1:20260717-010100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv @leshikus — could you review this small praktika fix? The GH-auth pre-step (gh auth login --with-token) hard-fails a whole job on a single transient GitHub API 5xx during token validation; this retries it up to 4x with backoff on transport-class errors only (401 bad-token stays fatal), reusing the existing Shell.check retries mechanism.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 17, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1502ba9]

Summary: ✅


AI Review

Summary

This PR makes Praktika retry gh auth login --with-token on a bounded set of transient GitHub API and transport failures instead of hard-failing a whole job on the first token-validation blip. The wiring itself looks reasonable and CI is green, but the new failure contract is not covered by an automated regression test, so I would still ask for that before merge.

Tests
  • ⚠️ [ci/praktika/gh_auth.py:137-143] The PR description promises two behaviors that are easy to regress here: transient HTTP 503 or timeout failures from gh auth login --with-token are retried, while permanent auth failures such as HTTP 401 still fail on the first attempt. There is existing ci/tests coverage for similar stderr-driven retry loops, so please add a small fake-gh regression test around GHAuth.auth_from_settings or GHAuth.auth that proves both cases.
Final Verdict
  • Status: ⚠️ Request changes

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 17, 2026
Comment thread ci/praktika/gh_auth.py
stdin_str=f"{access_token}\n",
strict=True,
retries=4,
retry_errors=_GH_AUTH_RETRY_ERRORS,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new contract here is "retry transient gh auth login --with-token failures, but still fail fast on auth-class errors". None of that is pinned in ci/tests yet. Because this pre-step gates every Praktika job and we already have executable-level regression tests for similar stderr-driven retry loops, please add a small fake-gh test that proves both sides: transient HTTP 503/timeout output is retried, while a permanent HTTP 401 still fails on the first attempt.

@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.

Great!

@alexey-milovidov alexey-milovidov self-assigned this Jul 17, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 17, 2026
Merged via the queue into ClickHouse:master with commit 1bc2ec6 Jul 17, 2026
178 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 17, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…th-retry-503

Retry gh auth token validation on transient GitHub API 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 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