Commit 2026-09-15 00:29 2bca5089
View on Github →feat(cache): put with native Azure and S3 backends (#43378)
This PR reworks the upload side of the cache tool. It prepares CI to upload to more than one storage location. The defaults stay the same: uploads continue to go to the Azure account, and the put-staged invocation in CI works unchanged.
Major changes:
Upload commands.:
put-stagedis moved to run before the expensive hash-memo build.- All upload commands share one write path:
runPutresolves the destination and dispatches to the selected backend.put-unpackedand thecommitcommands are removed; nothing in the tool reads a commit file. Backends: - The new
--backendoption selects the storage backend on every upload command:azure(the default) ors3. Each backend reads only its own credentials and resolves its own destination azuresigns with the OIDC bearer token and writes to the chosen--containeron the Azure account.s3signs each request with SigV4: a credential pair, an optional session token, and the regionMATHLIB_CACHE_S3_REGION. It writes the same container layout ({base}/{container}/{key}) under the bucket endpointMATHLIB_CACHE_PUT_BASE_URL, of the formhttps://endpoint/bucketTransfer tools:- selected by the backend:
azureuploads with curl (the built-in tool, as before);s3uploads with a system rclone when one works on PATH, and with curl otherwise - rclone receives the S3 credentials through its environment Clear upload boundary.:
- The new
Cache/Upload/modules hold everything that moves staged bytes. Upload/Azure.leanandUpload/S3.leaneach implement a complete backend: credential resolution, destination, tool choice, and the transfer entry point.Upload/Curl.leanandUpload/Rclone.leanhave the transfer mechanicsUpload/Dest.leanthe destination contractUpload/Defs.leanthe backend selection and the destination arbitration Documentation. The README andcache --helpdocument the public surface: reads, staging, and the external-cache interface. The upload commands, options, and variables are documented in the newCache/CI.md. Behavior changes beyond the new upload path:put-stagedwithout--staging-direxits with code 1. Before, it printed a message and exited 0, so a misconfigured CI job reported success and uploaded nothing.- An upload without
--container(and withoutMATHLIB_CACHE_PUT_URL) errors and names the known containers. Before, it defaulted to the baremathlib4container, so a misconfigured job wrote to the lowest-trust namespace. - A scope that is not a hex commit SHA causes an error. Before, a path-shaped
MATHLIB_CACHE_REPO_SCOPEcould reach URL paths and a local temp-file name. MATHLIB_CACHE_SASis retired: the tool does not read it. CI mints OIDC bearer tokens and the broker mints S3 pairs; nothing sets a SAS token.