From 2503193577fec3e88c45733cd73081e750c77718 Mon Sep 17 00:00:00 2001 From: Ulrich Hornung Date: Mon, 17 Aug 2026 23:55:40 +0200 Subject: [PATCH] fix(cache): wait for packed manifest discovery --- .github/workflows/ci.yml | 2 +- README.md | 4 ++-- action.yml | 2 +- action/main.js | 22 +++++++++++++++++----- action/main.test.js | 14 ++++++++++++++ dist/SHA256SUMS | 4 ++-- dist/cache-server-linux-amd64 | Bin 9744510 -> 9744510 bytes dist/cache-server-linux-arm64 | Bin 9044094 -> 9044094 bytes 8 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 action/main.test.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2348665..01ef01e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: run: go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 - name: Rebuild packaged binaries env: - VERSION: v0.3.0 + VERSION: v0.3.1 run: scripts/build-dist.sh - name: Verify packaged binaries are reproducible run: git diff --exit-code -- dist diff --git a/README.md b/README.md index ed26468..fb78ab6 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ Do not enable Bazel remote-cache compression with this release. | `max-blob-size-mb` | `512` | Maximum spooled upload/download size | | `max-concurrent-operations` | `4` | Backend-operation backpressure | | `max-uploads-per-minute` | `180` | Evenly spaced uploads; must be below 200 | -| `backend-timeout-seconds` | `300` | Per-operation timeout | +| `backend-timeout-seconds` | `300` | Timeout for one GitHub cache operation and initial packed-manifest discovery | | `port` | `0` | Loopback port; zero chooses a free dynamic port | The main step outputs `url`, `stats-url`, `writable`, `bazel-args`, and @@ -246,7 +246,7 @@ go vet ./... go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./... go run golang.org/x/vuln/cmd/govulncheck@v1.6.0 ./... node --test action/*.test.js -VERSION=v0.3.0 scripts/build-dist.sh +VERSION=v0.3.1 scripts/build-dist.sh git diff --exit-code -- dist (cd dist && sha256sum --check SHA256SUMS) ``` diff --git a/action.yml b/action.yml index eaf442d..c462575 100644 --- a/action.yml +++ b/action.yml @@ -50,7 +50,7 @@ inputs: required: false default: "180" backend-timeout-seconds: - description: "Timeout for one GitHub cache load or save" + description: "Timeout for one GitHub cache operation and initial packed-manifest discovery" required: false default: "300" port: diff --git a/action/main.js b/action/main.js index 9c5d5f4..5740db4 100644 --- a/action/main.js +++ b/action/main.js @@ -19,6 +19,13 @@ const { const sleep = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)); +function startupTimeoutMilliseconds(storageMode, backendTimeoutSeconds) { + // Packed mode restores every discoverable manifest before accepting Bazel + // requests. Its server-side discovery already has this deadline, so the + // wrapper must not report a false startup failure after a fixed 15 seconds. + return (storageMode === "packs" ? backendTimeoutSeconds : 15) * 1000; +} + function positiveInteger(name, fallback, maximum = Number.MAX_SAFE_INTEGER) { const value = Number.parseInt(input(name, String(fallback)), 10); if (!Number.isSafeInteger(value) || value <= 0 || value > maximum) { @@ -125,8 +132,9 @@ async function main() { fs.closeSync(logDescriptor); child.unref(); + const readyDeadline = Date.now() + startupTimeoutMilliseconds(storageMode, backendTimeoutSeconds); let ready; - for (let attempt = 0; attempt < 150; attempt += 1) { + while (Date.now() < readyDeadline) { if (fs.existsSync(readyFile)) { ready = JSON.parse(fs.readFileSync(readyFile, "utf8")); break; @@ -163,7 +171,11 @@ async function main() { ); } -main().catch((error) => { - process.stderr.write(`::error::${String(error.message).replaceAll("\r", "").replaceAll("\n", "%0A")}\n`); - process.exitCode = 1; -}); +if (require.main === module) { + main().catch((error) => { + process.stderr.write(`::error::${String(error.message).replaceAll("\r", "").replaceAll("\n", "%0A")}\n`); + process.exitCode = 1; + }); +} + +module.exports = { startupTimeoutMilliseconds }; diff --git a/action/main.test.js b/action/main.test.js new file mode 100644 index 0000000..a849eae --- /dev/null +++ b/action/main.test.js @@ -0,0 +1,14 @@ +"use strict"; + +const test = require("node:test"); +const assert = require("node:assert/strict"); + +const { startupTimeoutMilliseconds } = require("./main"); + +test("packed startup waits for its configured manifest-discovery deadline", () => { + assert.equal(startupTimeoutMilliseconds("packs", 300), 300_000); +}); + +test("object startup retains the short local-server readiness deadline", () => { + assert.equal(startupTimeoutMilliseconds("objects", 300), 15_000); +}); diff --git a/dist/SHA256SUMS b/dist/SHA256SUMS index 42aa1b6..43c5d05 100644 --- a/dist/SHA256SUMS +++ b/dist/SHA256SUMS @@ -1,2 +1,2 @@ -100dfdbf3729558bd6953d0e836f6d22a6d7f4e53e67bae289008de2e971e96b cache-server-linux-amd64 -5de1b5db9ffa1350bdda5ef1affcabad59be3527df3b7a2abd332d3a6c3e2bcd cache-server-linux-arm64 +9b7e9b76bfa605420a0c5498ff6b40864ecaffef3d2ef16203502a1786cf7e93 cache-server-linux-amd64 +08d858dfb6c528c79667c06d14d35575b9f32d05720656f4c13b6f1f39de4f91 cache-server-linux-arm64 diff --git a/dist/cache-server-linux-amd64 b/dist/cache-server-linux-amd64 index b746b5dfb00f01aa376278bf0b211f6029b78703..ed43d0f73826fc249c24015e51150026c65dcac5 100755 GIT binary patch delta 439 zcmWN=Q&I&00EW@2ZnkavX5047wr$+-Wn&>dG}9{Tp%t`}rvJ>GzuzCjpB`g@B~}=) z#s*vLu*U&MoN&ekSKM&N15dp0#s^>g@F##kf(RyrP{If&f=Hr>CWctzh$n$Wl1L_n zRE(sNP6nA|kxdS{W~iWh>q%*j_ZU@>Xc6FjLzzu&g+6M>XI(&imvLKuIq+w z>XvTnj_&H7?(2ab>XDlDSWom+&lEk^3%%4Uz1ADO)jPe{2Yu8hebyI!{ron+y&L}l Dp*7Q! delta 439 zcmWN=Q*HzR07cQ%wry)_+qP}noZ{BTLi*99tLS`m1zpLc?{a3Y8#ifCepC60I!NF<45Qb;8Y z1L}I;GP(qq91v^SYpmx}?jxqN}>5>$;(vx~1E? zqr1AN`+A^Kq5&blR_$Kq?17=S!9z#E_virKp{mGQ$i_alv6<^ zRaE1khFa=yVo*;5jWp3r3$3)#j*AXD>7tt+OnPzCM?V7${&<|G&EYjnj}Gauj_9b4 z>9|hlq)zFy&giVp>AWuJqAuyOuIQ?+>AG&{rf%uB?&z-W>AoK5p&se6p6IEb>A7C$ mrC#Z^-sr8~>AgPaqdw`gTKb}|`ljf+eyCSJe+~1?{r3--W|4^i delta 413 zcmWN=1x^D207bzRio3hJ7wO_qY$;OQ-QC?;;6dRg9Dsy`!!`U##%F!oeQIID4}a_g z5J(Wggb+#?;Y1Kg6w$;GOC0eekVq2Aq>xG)>12>e7TM&GOCI?YP)HHQlu$|;