Repository navigation
ci: retry Spark download in site guide tests - #5812
Conversation
The guide tests download Spark through the Apache mirror redirector. When the mirror/CDN returns a small non-gzip response, the test run fails with 'gzip: stdin: not in gzip format'. Fail curl on HTTP errors, retry, and fall back to archive.apache.org when the default download URL fails.
|
Hello @sririshindra, Thanks for the PR. However, I think this change is intentional: #2038 Thanks, |
ayushtkn
left a comment
There was a problem hiding this comment.
According to the policy we "must" use closer.lua only
https://infra.apache.org/release-download-pages.html#download-scripts
but adding retry maybe to all such commands looks fair enough to me
| curl_cmd = ["curl", "--location", spark_tarball_url] | ||
| urls = [spark_tarball_url] | ||
| if spark_tarball_url == SPARK_TGZ_URL: | ||
| urls.append(SPARK_TGZ_FALLBACK_URL) |
There was a problem hiding this comment.
This logic looks pretty complicated to me. Would adding retries to the curl command above not be sufficient?
There was a problem hiding this comment.
Yeah, maybe retries is the best way to go. Let me add retries with staggered exponetial backoff and hopefully that is enough to solve the transient failures. Let me update the PR.
… to another URL Replace the fallback-URL logic with a simple retry of the whole download and extract step, backing off exponentially with jitter between attempts.
orca-review-bot
left a comment
There was a problem hiding this comment.
Note
AI-generated review. Written by an agent. It can be wrong, so please push back where it is.
Nice fix. Retrying the whole curl | tar pipeline is the right call, since curl's --retry wouldn't catch the 200-with-non-gzip-body case you actually hit. The loop logic and the backoff tests look correct.
A few non-inline things:
- Every failure the tests simulate comes from tar. Can we add one to
site/it/test/test_spark.pywhere curl exits non-zero (e.g.FakeProc(22, stdout=FakeStdout())) and the next attempt succeeds? - The first commit had an archive.apache.org fallback that the second commit dropped. Was that requested? All five retries go back to the same
closer.luaURL within about 30s, so an outage lasting a few minutes will still fail the job. - Small one: can we retitle to Conventional Commits (e.g.
ci: retry Spark download in site guide tests) and drop the emptyFixes #?
No CHANGELOG or docs update needed for this.
|
|
||
|
|
||
| def _download_and_extract(url: str, spark_dir: Path) -> None: | ||
| curl_cmd = ["curl", "--location", "--fail", url] |
There was a problem hiding this comment.
If the mirror stalls instead of erroring, curl just sits there and the retry loop never kicks in. The job hangs until the Actions timeout. Can we add something like --connect-timeout 30 --speed-limit 1024 --speed-time 60 here so a stalled download fails fast and gets retried?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
There was a problem hiding this comment.
Added --connect-timeout 30 --speed-limit 1024 --speed-time 60 so a stalled download fails and gets retried.
| f"Downloading Spark failed ({e}), retrying in {delay:.1f}s (attempt {attempt}/{DOWNLOAD_ATTEMPTS})..." | ||
| ) | ||
| time.sleep(delay) | ||
| print("::endgroup::") |
There was a problem hiding this comment.
With line 57, if we exhausted all of the retry, it will raise and halt the script. In this case, line 65 is never print. Should we wrap this in a finally clause?
There was a problem hiding this comment.
Good catch. The retry loop is now wrapped in try/finally, so ::endgroup:: is always printed. Added a test for it.
Add curl connect and stall timeouts so a hung mirror fails fast and is retried, always close the log group when all attempts fail, and cover curl failures in the tests.
|
Thanks for the reviews. I pushed an update:
I did not restore the |
|
LGTM, thanks for the fix @sririshindra. |
flyrain
left a comment
There was a problem hiding this comment.
+1 Thanks @sririshindra !
|
Looking at https://github.com/apache/polaris/actions/runs/40397132814/job/121833012266?pr=5781, the retry doesn't appear to help. |
The
test-site-guidesCI job downloads Spark 3.5.8 through the Apache mirror redirector (closer.lua, which redirects todlcdn.apache.org) and pipes it intotar. On 2026-10-18 this job failed on two consecutive runs of an unrelated PR (#5721, spec-only) with:Failing runs/jobs:
The same job passed on other PRs/main earlier the same day and the day before (e.g. runs 39082544721, 38989844622, 39016950497), so this looks like a transient mirror/CDN problem: the download returned a small non-gzip body (about 452 bytes) rather than the tarball. I could not reproduce it locally; the redirect and the
archive.apache.orgcopy both respond normally from my machine.Current behavior:
curlhas no--failand there is no retry, so one bad response from the mirror fails the whole job.Change in
site/it/site_checks/spark.py:curlnow uses--fail, so HTTP errors produce a non-zero exit instead of an error page being piped intotar.curl | tarpipeline is retried, which also covers the case where the mirror returns a non-gzip body with a 200 status.Assumptions:
tar --gunzipalready rejects non-gzip responses.Tested: unit tests cover retry-until-success with backoff delays and giving up after the last attempt;
pytestinsite/itpasses andruff format/ruff checkare clean. I also ranensure_sparkagainst a local HTTP server that returned a 503, then a non-gzip 200, then a valid tarball, and it succeeded on the third attempt. The CI-only change needs no CHANGELOG or site docs update.Checklist
CHANGELOG.md(if needed) - not needed, CI-onlysite/content/in-dev/unreleased(if needed) - not needed, CI-only