From cc30e310b2e5322c690c954a634e8e4cc5935147 Mon Sep 17 00:00:00 2001 From: Wynne Pirini Date: Mon, 2 Nov 2026 11:31:30 +1300 Subject: [PATCH] fix(ci): stop the arm64 restart assertion failing on SIGPIPE The step runs under `set -euo pipefail` and tests the restart with docker logs calnode 2>&1 | grep -q "DEK unwrapped from keystore" `grep -q` exits as soon as it matches, so `docker logs` takes SIGPIPE and the pipeline returns 141 under pipefail. The assertion therefore fails even though the line was found. It is timing dependent, which is why it was intermittent: the failure dump in the same run printed the very line the assertion missed. Reproduced directly: `yes x | head -50000 | grep -q x` exits 141. This blocked a Dependabot PR that changes nothing related (#208, codeql-action). Capture the logs to a file with redirection, then grep the file, which cannot SIGPIPE. The same loop also retries for up to 20 seconds, covering Docker's log flush lagging the first successful HTTP response. The failure path now prints the tail of the log it actually searched. --- .github/workflows/docker-publish.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 56f52598..3a4ada50 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -238,10 +238,23 @@ jobs: code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/ || true) if [ "$code" = "200" ] || [ "$code" = "302" ] || [ "$code" = "307" ]; then echo "still serving after restart (HTTP $code)" - docker logs calnode 2>&1 | grep -q "DEK unwrapped from keystore" \ - && echo "restart reused the persisted key" \ - || { echo "::error::restart did not reuse the persisted key"; exit 1; } - exit 0 + # Read the logs into a file before searching them. `docker logs | grep -q` + # fails under `set -o pipefail` as soon as grep matches: grep exits, docker + # logs takes SIGPIPE, and the pipeline returns non-zero even though the line + # was found. It is timing dependent, which is why this assertion failed + # intermittently while the log dump below clearly contained the line. + # The retry also covers Docker's log flush lagging the first HTTP response. + for attempt in $(seq 1 20); do + docker logs calnode > /tmp/restart.log 2>&1 || true + if grep -q "DEK unwrapped from keystore" /tmp/restart.log; then + echo "restart reused the persisted key" + exit 0 + fi + sleep 1 + done + echo "::error::restart did not reuse the persisted key" + tail -20 /tmp/restart.log + exit 1 fi sleep 2 done