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 b746b5d..ed43d0f 100755 Binary files a/dist/cache-server-linux-amd64 and b/dist/cache-server-linux-amd64 differ diff --git a/dist/cache-server-linux-arm64 b/dist/cache-server-linux-arm64 index a3c9f73..d862d7c 100755 Binary files a/dist/cache-server-linux-arm64 and b/dist/cache-server-linux-arm64 differ