Skip to content

fix(pruner): evict Gradle 9 transforms, cap work dirs and add a host-wide Maven proxy - #47

Merged
azlekov merged 1 commit into
mainfrom
fix/pruner-gradle9-transforms
Nov 26, 2026
Merged

azlekov merged 1 commit into
mainfrom
fix/pruner-gradle9-transforms

Conversation

@azlekov

@azlekov azlekov commented Nov 26, 2026 •

Copy link
Copy Markdown

Closes #45.

Since 23 Nov, Android builds on beelink fail with a 429 from Maven Central on org.robolectric:nativeruntime-dist-compat:1.0.19. Sonatype limits downloads of each file per IP address and blocks this one for about 23 hours. The runners hit the limit because the pruner kept deleting downloaded dependencies, so every slot downloaded the same 150–190 MB Robolectric jars again. The full analysis is in this comment on #45.

This PR fixes the pruner and adds a host-wide Maven proxy, so each host downloads an artifact once.

Pruner

  • Gradle 9 transforms. Gradle 9 keeps transforms in caches/<version>/transforms, which no rule covered (only Gradle 8's caches/transforms-*). On slot 2 they were 23 GB against 1.1 GB of dependencies, so the pruner could only meet the budget by deleting dependencies. A new STORE_TABLE rule evicts these transforms oldest first.
  • Untracked bytes. The pruner now logs a warning when files no rule can delete take up more than a quarter of a slot's budget. The next cache layout change shows up in the log.
  • Idle slots. A slot that no runner has claimed for SLOT_IDLE_DAYS (default 7) gets no share of the budget and is emptied. The preflight records the claim time on slots/<id>/.lock. If every slot looks idle (the host was stopped), none is emptied.
  • Proxy cache. The proxy cache counts against the host budget before it is split, up to half of it, so a large proxy cache can never take a slot's budget to 0.
  • Work dirs. Nothing limited slots/<id>/work, where every repo a slot ever built keeps its checkout and build outputs: 68 GB on beelink, mostly repos untouched since October. WORK_BUDGET_BYTES (default 10 GiB per slot, 0 turns it off) now evicts whole work/<repo> checkouts, least recently used first. The runner recreates a missing checkout dir and actions/checkout clones the repo again. The runner's own work/_* dirs stay, a busy slot is skipped, and an idle slot loses every checkout.

Maven proxy

  • Service. A new maven-proxy service in docker-compose.yml (nginx:1.31.9-alpine) caches Maven Central, Google Maven and the Gradle Plugin Portal under ${RUNNER_DATA_DIR}/maven-proxy.
    • Its size is capped by MAVEN_PROXY_MAX_SIZE (default 20g).
    • Concurrent requests for one file share one download (proxy_cache_lock).
    • A 429 or other error is never cached.
    • Plugin Portal redirects are followed inside the proxy.
  • Gradle. The image ships maven-proxy.gradle, which the preflight installs into ~/.gradle/init.d. It points mavenCentral(), google() and gradlePluginPortal() at the proxy, and Robolectric too (robolectric.dependency.repo.url).
    • It warns about public repository URLs it does not rewrite.
    • It checks the proxy's /healthz once when a build starts. If the proxy does not answer, or MAVEN_PROXY=off, Gradle uses the repositories as declared.
  • Restarts. A proxy restart during a build fails that build, so recreate maven-proxy only while the runners are idle. The README says so.

Why a proxy and not GRADLE_RO_DEP_CACHE

Gradle can read a shared read-only dependency cache, which the pruner could seed from the slots. That cache has these limits:

  • It helps only after a seed pass, so until then every slot still downloads a new artifact itself.
  • It does not share concurrent first downloads.
  • It must match the cache layout of every Gradle version the projects use.
  • It cannot change while builds read it, so each seed copies and swaps a tree of many gigabytes.
  • It never covers the jars that Robolectric fetches itself.

An HTTP proxy has none of these limits. It works with any Gradle version and any Maven client, and builds fall back to the declared repositories when it is down. nginx was chosen over Reposilite because it needs no JVM and no admin account, keeps no state besides its cache, and shares concurrent downloads of the same file.

Tests

  • tests/pruner-gradle.sh: Gradle 9 transform eviction; the kotlin-dsl cache is kept; the untracked-bytes warning.
  • tests/pruner-budget.sh: proxy cache subtraction and its half-budget cap; an idle slot is emptied while the active slots keep their budget; nothing is emptied when every slot is idle.
  • tests/pruner-work.sh: the oldest checkout goes whole and work/_* stays; no limit with WORK_BUDGET_BYTES=0; a busy slot is left alone; an idle slot loses its checkouts while an active one keeps its own.
  • tests/maven-proxy.sh: the preflight installs the init script and replaces an old copy; the nginx cache against a fake upstream; Gradle 9.9.2 resolves through the proxy and falls back when it is down.
  • tests/image-smoke.sh: the init script is in the image.

All pass locally, and shellcheck reports nothing.

Rollout

After merge, build the image and update RUNNER_IMAGE on each host. Run docker compose up -d while the runners are idle, so maven-proxy starts before the runners pick up jobs.

🤖 Generated with Claude Code

@azlekov azlekov changed the title fix(pruner): evict Gradle 9 transforms and add a host-wide Maven proxy fix(pruner): evict Gradle 9 transforms, cap work dirs and add a host-wide Maven proxy Nov 26, 2026
…wide Maven proxy

Maven Central answered 429 on beelink for Robolectric's 151 MB nativeruntime-dist-compat jar: a per-IP, per-file limit. Every slot kept
downloading it again because the pruner could not see Gradle 9's caches/<version>/transforms (23 GB against 1 GB of dependencies on one slot)
and evicted dependencies to meet the budget instead.

Pruner:
- Evict caches/*/transforms/* units, and warn when bytes no STORE_TABLE rule covers pass a quarter of a slot's budget.
- Split the budget over active slots only. A slot no runner claimed for SLOT_IDLE_DAYS (7), and whose .lock no live runner holds, is emptied;
  the preflight records the claim time on the slot's .lock.
- Take the maven-proxy cache off the host budget before the split, at most half of it.
- Cap each slot's work dir with WORK_BUDGET_BYTES (10 GiB, 0 = off): whole work/<repo> checkouts go, least recently used first; work/_* stays.

Maven proxy:
- A maven-proxy compose service (nginx) caches Maven Central, Google Maven and the Gradle Plugin Portal under RUNNER_DATA_DIR/maven-proxy,
  shares one upstream download between concurrent misses, never caches a 429, and follows redirects (absolute or path-only) inside the proxy.
- The image ships maven-proxy.gradle, installed by the preflight into ~/.gradle/init.d. It points the three repositories and Robolectric at
  the proxy when /healthz answers at build start, and leaves builds as declared when it does not or MAVEN_PROXY=off.

Tests cover Gradle 9 transforms, the untracked-bytes warning, idle and held slots, the proxy budget share, work dir eviction, the proxy cache
against a fake upstream and Gradle 9 through the init script.

Closes #45

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@azlekov
azlekov force-pushed the fix/pruner-gradle9-transforms branch from 0948457 to 125941a Compare November 26, 2026 07:30
@azlekov
azlekov enabled auto-merge (squash) November 26, 2026 07:33
@azlekov
azlekov merged commit 4b43bfa into main Nov 26, 2026
12 checks passed
@azlekov
azlekov deleted the fix/pruner-gradle9-transforms branch November 26, 2026 07:37
azlekov added a commit that referenced this pull request Nov 26, 2026
…ate CA (#49)

nginx's proxy_ssl_verify_depth defaults to 1: one CA between the leaf and a trusted root. Maven Central's chain runs through Let's Encrypt's
Root YE, which Alpine's bundle does not trust, and on to ISRG Root X2 and X1, so every Maven Central download through the proxy failed 502
("unable to get local issuer certificate") after the rollout of #47. Google Maven and the Plugin Portal were unaffected.

The proxy test's fake upstream spoke plain HTTP, so it never verified a chain. It now serves HTTPS with two intermediate CAs and fails 502
without the fix.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

bug: Maven Central answers 429 to Gradle on beelink-runner-4 and blocks kodni-mobile PR checks

1 participant