Skip to content

fix(maven-proxy): fetch from a Central mirror when Maven Central answers 429 or 5xx - #50

Merged
azlekov merged 2 commits into
mainfrom
fix/maven-proxy-central-fallback
Nov 26, 2026
Merged

azlekov merged 2 commits into
mainfrom
fix/maven-proxy-central-fallback

Conversation

@azlekov

@azlekov azlekov commented Nov 26, 2026

Copy link
Copy Markdown

Problem

The proxy from #47 started with an empty cache and only caches a 200. Maven Central keeps answering 429 for Robolectric's org.robolectric:nativeruntime-dist-compat:1.0.20 (165 MB), so the proxy never got a copy and passed the 429 on. Every Android build that runs unit tests failed, e.g. dodi-smart/nis-inventory-android#95 (three attempts). Central answers that file with 429 even from outside the runner host, while Google's mirror of Central serves it.

Change

  • maven-proxy/default.conf.template: /maven2/ gets its own locations. Central's 429/500/502/503/504 goes to @central_mirror (or @central_mirror_metadata, which keeps the 10-minute TTL), which fetches the same path from MAVEN_CENTRAL_MIRROR_URL. The response is cached under the same key, so the next request is a HIT. Redirect handling is kept in those locations, since a location-level error_page replaces the server's.
  • docker-compose.yml: MAVEN_CENTRAL_MIRROR_URL, defaulting to https://maven-central.storage-download.googleapis.com/maven2. Set it to MAVEN_CENTRAL_URL to turn the fallback off.
  • Google Maven and the Plugin Portal are unchanged; their errors still pass through.
  • README and .env.example document the fallback.

Tests

tests/maven-proxy.sh gains cases for these:

  • Central 429 → mirror 200 → cached (HIT, one fetch from each).
  • Central 503 → mirror.
  • Metadata falls back to the mirror.
  • When both answer 429, the 429 passes through and isn't cached.
  • Google's 429 never reaches the mirror.

The proxy section passes locally (OrbStack). On the previous config, 11 checks fail. The Gradle section was skipped locally (no plain gradle on PATH), and this change doesn't touch the init script.

Rollout

docker compose up -d maven-proxy on each host while the runners are idle.

🤖 Generated with Claude Code

azlekov and others added 2 commits November 26, 2026 11:47
…ers 429 or 5xx

A cold cache could not fill while Central rate-limited the host: the proxy only caches a 200,
so Robolectric's nativeruntime jar failed every build with 429. Central's 429 or 5xx now sends
the request to MAVEN_CENTRAL_MIRROR_URL (Google's mirror of Central by default), and the mirror's
copy is cached under the same key. Google Maven and the Plugin Portal are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…document its limits

- The mirror lags Central, so its 404 after Central's 429/5xx is no longer cached under Central's key
- Document that the mirror must serve files itself (its redirects are not followed)
- Fix docs: pointing MAVEN_CENTRAL_MIRROR_URL at Central only asks Central again, it does not turn the fallback off
- Test Central 503 + mirror 404; upstream_hits counts access-log lines only; Google 429 test no longer depends on earlier counts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@azlekov
azlekov enabled auto-merge (rebase) November 26, 2026 10:07
@azlekov
azlekov merged commit 5780bae into main Nov 26, 2026
12 checks passed
@azlekov
azlekov deleted the fix/maven-proxy-central-fallback branch November 26, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant