Uh oh!
There was an error while loading. Please reload this page.
fix(k3s-cuda): stop the --exclude diagnostic from killing its own error path (#656) - #678
Merged
Merged
Conversation
…or path
`build.sh` runs under `set -euo pipefail`. The verify branch printed matching
paths with `grep … | head >&2`, so once the matching set outgrows the ~64KB pipe
buffer, head's early close SIGPIPEs grep (141), pipefail propagates it and
errexit aborts the script BEFORE the `rm -f "${rootfs}"` cleanup and before the
intended `exit 1`. The diagnostic killed the error path it was added to explain:
the extracted rootfs leaks and the build reports 141 instead of 1.
Size-dependent, which is why it hid: measured 50 matching lines exit 1 (output
fits the buffer, no signal) and 20k exit 141.
Switched to the house here-string idiom rather than bolting on `|| true` —
scripts/lib/install-client-helm.sh already documents this exact mechanism
("Herestring, NOT `printf … | head -n 3`", same ~64KB/141 reasoning), as do
scripts/lib/cluster.sh, scripts/check-facts.sh and .github's conformance-gate.
This file was simply a straggler that missed the memo.
Verified with the new shape at 20k matching lines: exit 1, rootfs cleaned up.
shellcheck + bash -n clean.
Closes#656 (its flap-lockout half was already fixed in
client/templates/image-refresh-cronjob.yaml).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>saadqbal
approved these changes
Aug 12, 2026
saadqbal
left a comment
Contributor
There was a problem hiding this comment.
Nice, careful PR 👍 Confirmed the SIGPIPE-under-pipefail abort locally (20k matches → old pipeline exits 141 and skips the rm+exit 1; here-string version exits 1 as intended), and the diagnostic still prints its 10 lines. The || true only neutralizes the grep inside the if-branch (where a match is already guaranteed), so no genuine verify failure gets swallowed and the check isn't a no-op.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes#656. The ticket's flap-lockout half is already fixed on develop (
image-refresh-cronjob.yamlclears the flap annotation once a rollout settles), so this is the remaining pipefail half.The bug
docker/k3s-cuda/build.shruns underset -euo pipefail, and the verify branch printed its findings with:headcloses the pipe after 10 lines. Once the matching set outgrows the ~64KB pipe buffer,greptakes SIGPIPE (141),pipefailpropagates it, anderrexitaborts before therm -fcleanup and before the intendedexit 1.So the diagnostic killed the error path it was added to explain: the extracted rootfs leaks, and the build reports 141 instead of 1.
Why it hid: it's size-dependent. Measured — 50 matching lines exit 1 (output fits the buffer, no signal), 20k matching lines exit 141. A small corrupted image looks fine; a badly corrupted one loses both the cleanup and the exit code.
The fix
Switched to the house here-string idiom rather than bolting
|| trueonto the pipeline. This repo already documents this precise mechanism in four places —scripts/lib/install-client-helm.sh("Herestring, NOTprintf … | head -n 3", same ~64KB / rc=141 reasoning),scripts/lib/cluster.sh,scripts/check-facts.sh, and.github's conformance-gate.build.shwas simply a straggler that missed the memo, so it now matches the established pattern instead of inventing a second one.Verification
shellcheck -S warning/bash -nFollow-up (not in this PR)
The same scan turned up other
\| headpipelines underpipefailthat may carry the same hazard —scripts/install.sh:538,scripts/tests/check-drift.sh:77,123,docs/migration-tools/migrate-tenant.sh:242. Most look benign (tiny outputs), but "benign because the output is small today" is exactly how this one survived. Filed separately rather than widened into this fix.Note
Low Risk
Narrow shell fix on a build-script error diagnostic only; verification logic and success path are unchanged.
Overview
Fixes the k3s-CUDA image rootfs verify error path so a large
--excludematch set no longer aborts underpipefailbefore cleanup.In
docker/k3s-cuda/build.sh, replacesgrep … | headwith the repo’s here-string idiom (matches="$(grep … || true)"thenhead <<< "${matches}"). That stopsheadfrom SIGPIPEinggrep(exit 141), so the path still prints diagnostics, removes the temp rootfs, and exits 1 as intended.Reviewed by Cursor Bugbot for commit 9e19fdd. Bugbot is set up for automated code reviews on this repo. Configure here.