Skip to content

The cache servers on every runner host, turbow rewritten, and the cache host as a template answer - #72

Open
davidjalbers wants to merge 22 commits into
plain-pipelinefrom
davidjalbers/plx-226-the-cache-servers-on-every-runner-host
Open

davidjalbers wants to merge 22 commits into
plain-pipelinefrom
davidjalbers/plx-226-the-cache-servers-on-every-runner-host

Conversation

@davidjalbers

@davidjalbers davidjalbers commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

The two Turbo cache servers move from a step of every job onto the runner hosts, as the role plexus.ci.turbo_cache.
turbow is rewritten to find its server by verb, job, environment and the new answer turbo_cache_host.
The step turbo-cache and its place in _check.yml leave.

What changes

  • plexus.ci.turbo_cache runs ci-turbo-cache@shared (8585, <owner>-ci-turbo) and ci-turbo-cache@trusted (8586, <owner>-ci-turbo-trusted), instances of one template unit.
    By default they listen on loopback only, with tokens the host generates once and keeps.
    With turbo_cache_overlay: true they listen on 0.0.0.0 with the fixed tokens CI_TURBO_SHARED_TOKEN and CI_TURBO_TRUSTED_TOKEN from the run's environment, and a firewall fragment admits 8585 and 8586 on turbo_cache_overlay_interface (default wt0) only.
    The buckets' keys come from CI_TURBO_S3_ENDPOINT, CI_TURBO_S3_REGION, CI_TURBO_{SHARED,TRUSTED}_{ACCESS,SECRET}_KEY, and are written to root-only files that systemd reads before it starts the server.
    What a slot is handed is /etc/ci-turbo-cache/slot.env (PLX_TURBO_SHARED, PLX_TURBO_SHARED_TOKEN, PLX_TURBO_TRUSTED, PLX_TURBO_TRUSTED_TOKEN), and the same as the facts turbo_cache_{shared,trusted}_{url,token}.
    No slot is handed anything yet: that is for the follow-up.
  • repo-turbo asks turbo_cache_host (a host name or IPv4 address, or empty) and renders it as PLX_TURBO_CACHE_HOST in [env] of mise.toml.
  • turbow: check and test use the shared server.
    build, e2e and publish use the trusted server in a job of the forge (GITHUB_ACTIONS=true), with TURBO_CACHE=remote:rw and so no local cache, and the shared server outside a job.
    The server comes from PLX_TURBO_SHARED/PLX_TURBO_TRUSTED, then from http://$PLX_TURBO_CACHE_HOST:8585/8586.
    The tokens come from PLX_TURBO_SHARED_TOKEN/PLX_TURBO_TRUSTED_TOKEN.
    turbow says in one line when it runs without a remote cache: no server named, no shared token, no node on PATH to ask the server with, a server that does not answer within two seconds or answers other than 200 or 401, or a server that refuses the token.
    A job with a trusted server and no trusted token fails in one line.
    Every remote-cache variable of the caller's shell is unset before Turbo runs, and TURBO_TEAMID is handed over empty, so a linked repo's team id (.turbo/config.json) never reaches a server.
  • .github/actions/turbo-cache, its step in _check.yml, its tests and the composite-action runner of the newborns are deleted.

Decisions the issue left open

  • The servers are a role of their own, plexus.ci.turbo_cache, not tasks of actions_runners.
    That way they can be tested without Docker or the CI App, and a cache host needs no slots.
    The playbook mounts it after actions_runners and before the firewall play.
  • The server binary is installed from its GitHub release (brunojppb/turbo-cache-server 5.0.4, the musl asset) by version and SHA-256, not as a container.
  • Each server runs under DynamicUser=yes as a user of its own, User=ci-turbo-cache-%i, so the shared server, which development machines reach, cannot read the trusted one's environment.
  • The role starts and restarts its servers by looping over the instances' names, because Ansible prints a looped item at -v whatever its label, and an instance holds its keys and token.
    Every task whose item or content holds a secret has no_log.
  • Restart=always, RestartSec=2s, StartLimitIntervalSec=0, and no LogsDirectory=: with one, the server would also write an unrotated log file.
  • The generated tokens are 64 characters of [a-z0-9], written once with force: false.
    A fixed token, set on the cache host, replaces the file on every run.
  • turbow probes /v8/artifacts/status with the token (2 s timeout): 200 means the server is used, 401 means it "refuses the token", and anything else means "nothing answers".
  • turbo_cache_host is validated by character class ([a-z0-9.-]), since the template engine has no regex.
    A URL, a port, upper case and spaces are refused.
  • In a job, a trusted verb with no server named still runs with TURBO_CACHE=remote:rw and no API, so it never reads a local cache that a shared run may have filled.
  • _check.yml keeps its inputs vault and op-service-account-token.
    The deleted step was what used them; whether they go is the follow-up's call, since callers pass them.

Left as they are, outside this change

  • The header comment of newborns/pipeline.test.ts still says the caches are "the cache servers the step turbo-cache starts".
  • tests/runner-image-commands.sh still names "the composite actions under .github/actions" and lists what turbo-cache.sh used.
  • _e2e.yml and _publish-deploy.yml still use the deleted step ($/.github/actions/turbo-cache), as do the tests of them in packages/lib/src/pipeline.test.ts.
    Those workflows are replaced in the follow-up.

Verified at ab2fac3

  • On the forge the tests inherit GITHUB_ACTIONS=true, so a newborn's build was a trusted verb of a job: with no trusted server named, turbow gives it no local cache, and two app-nextjs newborn tests of a build's cache hits failed there (seen in the run's log and reproduced locally).
    The newborn harness now drops the inherited GITHUB_ACTIONS: a newborn's verbs run outside a job unless a test passes GITHUB_ACTIONS=true itself, as the cache and pipeline newborns do.
  • TURBO_FORCE=true mise run test passes: 7 of 7 tasks (at 7a8b0cb, before this test-only change).
  • The full e2e passes three times at ab2fac3, with GITHUB_ACTIONS=true CI=true, with CI=true alone, and with neither: 102 of 102 each.
  • newborns/turbo-cache.test.ts runs the role at -vvv in default and overlay mode, on a first run and on runs that restart the servers, and the output holds no bucket key and no token, fixed or generated.
    Turbo 2.11.13 sends a linked repo's team id when run alone, and never through turbow.
  • packages/lib/src/repoTurboCache.test.ts kills these mutations: a probe timeout of 20 s or none, a 500 taken for a server to use, and a non-empty GITHUB_ACTIONS taken for a job.

Lines

+1164 / −1259 against plain-pipeline (882c036).
The additions that stay are the role (260 lines, about half of them its header and comments), the rewritten tests of turbow and of the newborn (the role runs in a systemd container on two networks, and a newborn reaches it), and the question with its rendering.
The action, its shell script, its tests and the composite runner (783 lines) are gone.

🤖 Generated with Claude Code

davidjalbers and others added 12 commits December 2, 2026 04:08
…LX_TURBO_CACHE_HOST (PLX-226)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st, and probes it with the token (PLX-226)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… host, and probes it with the token (PLX-226)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…born app repo that reaches it (PLX-226)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s/plx-226-the-cache-servers-on-every-runner-host

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@davidjalbers davidjalbers self-assigned this Dec 2, 2026
davidjalbers and others added 10 commits December 2, 2026 04:51
…at -v prints no key or token (PLX-226)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eaches the server (PLX-226)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…te cache and says so (PLX-226)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… and GITHUB_ACTIONS=false for no job (PLX-226)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s/plx-226-the-cache-servers-on-every-runner-host

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…says otherwise (PLX-226)

On the forge the tests inherit GITHUB_ACTIONS=true, which made every
newborn's build a trusted verb of a job: without a trusted server it
reads no local cache, and the tests of a build's cache hits failed.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant