Repository navigation
feat: serve the cache service v2 API from the cache server - #6
Merged
Merged
Conversation
actions/cache@v4 (@actions/cache >= 4) switches to the Twirp CacheService API when ACTIONS_CACHE_SERVICE_V2 is set. The cache server now answers it at the root of its origin, with Azure-blob-style uploads and plain downloads at signed /cache-v2/ URLs, on the same store as the v1 API. - CacheStore::reserve / commit are shared by v1 and v2; gc also removes the blocks of abandoned v2 uploads. - UrlSigner replaces ArtifactStore's sign/verify; the cache gets its own key and kinds, so artifact and cache URLs cannot open each other. - The job's cache-mode travels as a runthrough_cache_mode claim in the runtime token (RuntimeAuth::claims); Twirp calls need the run's token. - job_env sets ACTIONS_CACHE_SERVICE_V2 and, without the artifact server, ACTIONS_RESULTS_URL at the cache origin; the artifact port forwards the v2 routes. With the caller's own token, only write jobs get v2. - The cache port answers ArtifactService calls with a JSON bad_route pointing at --artifact-server-path.
…eaks - Answer the v2 Twirp calls with proto field names, so the toolkit masks the signatures of signed_upload_url / signed_download_url before logging. - Give jobs that stay on v1 under the caller's token an empty ACTIONS_CACHE_SERVICE_V2, so a host job cannot inherit v2. - Stage uploads in a temporary file and rename them into place under the lock while the entry is still pending; only Finalize publishes the staging file as the blob, so a late PUT never changes a committed or dropped entry. - Refuse a second CreateCacheEntry while a reservation of the same key and version is in use (409 already_exists), and commit only the caller's own reservation on Finalize. v1 still replaces a pending reservation. - Make Put Block List atomic and repeatable: blocks stay until the upload is finalized (cache) or FinalizeArtifact (artifacts). - Count uploads as use for gc, remove the files of dropped or replaced reservations, and persist new reservations. - Sign blob URLs for the --cache-server-external-url origin on the cache port. - Refuse unparsable or negative size_bytes and missing upload data, answer a non-object body with 400 malformed, and never repeat the key in a message.
…ions - Restore the artifact server's Put Blob, Put Block and Put Block List handling to write in place as before; the staged, atomic upload path now serves the cache v2 API only. - The v1 PATCH, commit and download routes refuse a pending v2 reservation (404, nothing changed); a v1 reservation is still committed by v1. - A successful v1 PATCH refreshes the reservation's last use, so neither gc nor a v2 CreateCacheEntry takes an active v1 upload for abandoned. - CreateCacheEntry creates no file: FinalizeCacheEntryUpload succeeds only after a Put Blob (zero bytes included) or a Put Block List placed data. - Refuse a block list that does not parse and an unknown comp with 400, leaving the staged upload as it was.
- job_env adds a random jti claim, so two jobs whose names coincide (as --reuse names can) no longer share a token, and one cannot finalize the other's cache v2 reservation. - A v1 PATCH whose reservation was dropped while the chunk was written answers 404 and removes the chunk's file, instead of 204.
Byte ranges (x-ms-range or Range) and HEAD on /cache-v2/download/, and a 409 conflict that carries a message saying "already exists" so the Go client treats it as os.ErrExist and moves on to the next index key.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The local cache server now answers the GitHub cache service v2 API (
ACTIONS_CACHE_SERVICE_V2), whichactions/cache@v4uses, from the same store as the v1 API. It was listed under "Not supported" until now.src/servers.rs): TwirpCacheService(CreateCacheEntry,FinalizeCacheEntryUpload,GetCacheEntryDownloadURL) at the root of the cache port, forwarded from the artifact port when--artifact-server-pathis set, plus signed/cache-v2/upload|download/<id>blob URLs (Put Blob, Put Block, Put Block List).ACTIONS_CACHE_SERVICE_V2=truewhile the cache server runs and, without--artifact-server-path, anACTIONS_RESULTS_URLat the cache server.ACTIONS_CACHE_URL(v1) is unchanged.runthrough_cache_modeclaim). Under the caller's ownACTIONS_RUNTIME_TOKEN, non-writejobs are pointed at v1 by default, which still enforces the mode.jti).type=gha): with the flag set, buildx uses v2 as well, so the download route serves byte ranges andHEAD, and the 409 answer is one its Go client recognises.docs/specs/cache-v2.md.Changes to existing behaviour
index.jsonat once, a successfulPATCHrefreshes it for gc, aPATCHwhose reservation was dropped meanwhile answers 404, and v1 routes answer 404 for a reservation id made through v2.UrlSigner) and the cache v2 routes are forwarded; upload handling is as before.Testing
make check CARGO_FLAGS=--offline: pass (130 unit tests, 46 e2e).cargo test --offline --test e2e -- --ignored real_actions_cache_v4_saves_and_restores_through_v2 cache_and_artifact_servers_roundtrip real_upload_and_download_artifact_v3_and_v4: pass. The first runs the realactions/cache@v4withACTIONS_CACHE_URLblanked, so only v2 can serve it.make ci CARGO_FLAGS=--offline: pass.runner::tests::tool_cache_lock_is_taken_in_turn_and_given_up_on_cancelfailed once onmainbefore this work and passed on rerun (flaky, not touched here).Not confirmed
docker/build-push-actionwithtype=ghashould be tried before a release; a job can stay on v1 withenv: { ACTIONS_CACHE_SERVICE_V2: "" }.Known limits (not addressed)
ACTIONS_RUNTIME_TOKENthe server cannot tell jobs apart.FinalizeCacheEntryUploadafter a lost success answer getsok: false(the entry is saved).