Skip to content

Commit 4795d04

Browse files
authored
fix(ci): stop the layer-cache prune from being able to fail a build (#7252)
The settle loop added in 4f65103 reads `cur="$(total)"`, and composite steps run under `bash -e -o pipefail`, where an assignment takes its command substitution's exit status. So any failing `buildctl du` aborts the step and fails the build. `echo "$(total)"` survives the same failure, which is why this was invisible in the paths that ran first. That is not hypothetical. Deleting a sticky disk out from under a running job makes buildkitd panic inside cache.(*cacheManager).DiskUsage, and it took a Build AMD64 job down that way. `grep` also exits 1 whenever du prints no Total line, so an empty cache would have done it too. A cache-hygiene step must never be able to fail a deploy, so `total()` now always returns 0. The prune's own failure was already handled — it is an `if` condition, and a failing condition does not trip `-e`.
1 parent 4f65103 commit 4795d04

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

.github/actions/docker-build/action.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,16 @@ runs:
119119
120120
# Print the whole Total line rather than picking a column: buildctl's du
121121
# table is whitespace-aligned and its layout is not a stable contract.
122-
total() { sudo buildctl --addr "$addr" du 2>/dev/null | grep -iE '^total:' | tr -s ' \t' ' '; }
122+
#
123+
# The trailing `|| true` is load-bearing. Composite steps run under
124+
# `bash -e -o pipefail`, where `cur="$(total)"` takes the substitution's
125+
# exit status, so a failing du would abort the step and fail the build --
126+
# `echo "$(total)"` survives but the assignment in the settle loop does
127+
# not. buildctl exiting non-zero here is entirely plausible: deleting a
128+
# sticky disk out from under a running job makes buildkitd panic inside
129+
# DiskUsage, and grep also exits 1 whenever the table has no Total line.
130+
# Cache hygiene must never be able to fail a deploy.
131+
total() { sudo buildctl --addr "$addr" du 2>/dev/null | grep -iE '^total:' | tr -s ' \t' ' ' || true; }
123132
echo "before prune -> $(total)"
124133
125134
if sudo buildctl --addr "$addr" prune --all --keep-storage "$KEEP_MB"; then

0 commit comments

Comments
 (0)