Skip to content

Make previous-release package downloads resilient to infrastructure flakes - #107916

Merged
alexey-milovidov merged 3 commits into
masterfrom
ci-resilient-release-package-download
Jun 20, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
ci-resilient-release-package-download

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jun 18, 2026 •

Copy link
Copy Markdown
Member

The Upgrade check downloads the previous stable release .deb packages during the setup phase. A transient hiccup that exhausted the small retry budget there (5 attempts, ~45s of total backoff) used to abort the whole job before the actual test ran, and was recorded only as a generic Download script exit code row with an OK status — making it hard to recognize as infrastructure noise.

Reported here: #102817 (comment) (job log: https://github.com/ClickHouse/ClickHouse/actions/runs/27117485031/job/80044635535).

This makes the package download path resilient and self-diagnosing.

download_build_with_progress:

  • configurable retries count;
  • capped exponential backoff (DOWNLOAD_RETRY_MAX_BACKOFF), so raising the retry count extends the total retry window instead of exploding the per-attempt sleep;
  • fail fast on a genuine 404 (the artifact was never uploaded) instead of burning the whole retry budget;
  • treat a truncated response (short read vs. content-length) as a transient failure rather than producing a corrupt file that only surfaces later as an opaque dpkg error;
  • log the HTTP status / error and attempt number on each retry.

download_packages (download_release_packages):

  • retry the release packages more persistently (RELEASE_PACKAGE_DOWNLOAD_RETRIES);
  • stop silently skipping a missing essential package (the ones install_packages installs) — raise a clear, attributable error that distinguishes a genuine 404 from a transient failure, while still tolerating a hiccup on unused extra assets such as clickhouse-keeper.

Unit tests added in ci/tests/.

Related: #102817

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

Not required (CI improvement).

🤖 Generated with Claude Code

Version info

  • Merged into: 26.6.1.1057

The Upgrade check downloads the previous stable release `.deb` packages
during setup. A transient hiccup that exhausted the small retry budget
there (5 attempts, ~45s of total backoff) used to abort the whole job in
the setup phase before the actual test ran, and was recorded only as a
generic `Download script exit code` with an `OK` status - making it hard
to attribute as infrastructure noise.

Improve `download_build_with_progress`:
- accept a configurable `retries` count;
- cap the exponential backoff (`DOWNLOAD_RETRY_MAX_BACKOFF`) so raising
  the retry count extends the total retry window instead of exploding the
  per-attempt sleep;
- fail fast on a genuine `404` (the artifact was never uploaded) instead
  of burning the whole retry budget;
- treat a truncated response (short read vs. `content-length`) as a
  transient failure rather than producing a corrupt file that only
  surfaces much later as an opaque `dpkg` error;
- log the HTTP status / error and attempt number on each retry.

In `download_packages` (`download_release_packages`):
- retry the release packages more persistently
  (`RELEASE_PACKAGE_DOWNLOAD_RETRIES`);
- stop silently skipping a missing essential package (the ones
  `install_packages` installs) - raise a clear, attributable error that
  distinguishes a genuine `404` from a transient failure, while still
  tolerating a hiccup on unused extra assets such as `clickhouse-keeper`.

Add unit tests for both.

#102817 (comment)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [13f7ec4]

Summary: ✅


AI Review

Summary

This PR makes previous-release package downloads in Upgrade CI more resilient and fail-closed: download_build_with_progress now has configurable capped retries, fast 404 handling, and truncated-response detection; download_release_packages validates every required package; and upgrade_runner.sh stops at the download boundary on failure. The focused Python and shell tests cover the main contract, and the previously opened bot thread is fixed in the current code.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 18, 2026
Comment thread tests/ci/download_release_packages.py Resolved
@alexey-milovidov
alexey-milovidov requested a review from maxknv June 18, 2026 22:58
Address review (#107916):
`download_packages` only flagged required packages that were present in
`release.assets` and then failed to download. A partially published
release could expose `clickhouse-common-static_..._amd64.deb` (enough for
`get_previous_release_tag` to select the tag) while still lacking
`clickhouse-client_..._amd64.deb`; the missing asset never entered the
download loop, so the function returned success and the job later died
with an opaque `dpkg` glob error inside `install_packages`.

Now `download_packages` also validates that every required prefix has a
matching `_amd64.deb` asset and folds both failure modes (failed download
and absent asset) into a single attributable `DownloadException`. The
debug-symbols package is made required only in debug mode, since that is
the only mode that downloads and installs it.

Adds `test_missing_required_package_raises` (a partially published
release missing `clickhouse-client_`) and
`test_missing_dbg_is_required_only_in_debug_mode`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`download_release_packages` now exits nonzero when a required
previous-release package is missing or fails to download, but the only
shell caller, `tests/docker_scripts/upgrade_runner.sh`, ran it inside an
`&& ... || ...` list, so `set -e` did not stop on the nonzero status. The
follow-up guard only checked `clickhouse-common-static_*.deb` and
`clickhouse-server_*.deb`, so a missing `clickhouse-client_..._amd64.deb`
or `clickhouse-common-static-dbg_..._amd64.deb` could still slip through
to `install_packages` and die there with an opaque `dpkg` glob error -
exactly the failure mode this PR set out to make clear and attributable.

Handle the download exit code explicitly: on failure, record the `FAIL`
row, write a `failure` status to `check_status.tsv`, and `exit 1` before
`install_packages` can run; on success, record the `OK` row and continue.

Add `ci/tests/test_upgrade_runner_download_boundary.py`, which extracts
the real download block from the runner (between stable anchor comments)
and runs it under bash with a stub `download_release_packages`, proving a
failed download stops before `install_packages` is reached and a
successful one proceeds. Extracting the live block keeps the test from
drifting from the script it guards.

Addresses review feedback:
#107916 (comment)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 19, 2026
Merged via the queue into master with commit b531185 Jun 20, 2026
166 checks passed
@alexey-milovidov
alexey-milovidov deleted the ci-resilient-release-package-download branch June 20, 2026 00:22
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 20, 2026
JonSnow1807 pushed a commit to JonSnow1807/ClickHouse that referenced this pull request Nov 8, 2026
…ase debs

`download_release_packages.py` downloaded every previous-release deb from
the GitHub release only. On 2026-11-08 github.com answered 504/502/read
timeouts for about two hours ("Increase in timeouts for some
unauthenticated users"), longer than the 10-retry window from ClickHouse#107916
(6-10 min per file), and `Upgrade check (amd_release)` failed with
`Download script failed` on 10 unrelated PRs.

The same files are published to the ClickHouse Debian pool
(https://packages.clickhouse.com/deb/pool/main/c/clickhouse/<asset name>);
for v26.10.2.103 all six amd64 debs there have the GitHub asset size and
sha256. A version that is not in the pool yet (about 30 minutes after a
release) answers a real 404, so the existing 404 fast-fail applies.

Each package now gets the pool as a second source. After GitHub has
failed one package, the rest of the run tries the pool first, so an
outage costs one retry window per job rather than one per package. Once
a required package cannot be obtained from either source the loop stops,
since the job fails anyway. GitHub stays the first source, so a healthy
run makes the same requests as before.

Validated locally with a stub that returns 504 for every GitHub URL:
master fails with the CI message; this change downloads all six debs from
the real pool with matching digests and contacts GitHub only for the
first package. No test is committed (test infrastructure).

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

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