Repository navigation
fix(hack): avoid a SIGPIPE false-negative in the resourcesPreset check - #4204
Conversation
check-rd-presets.sh tests each expected preset with `printf '%s\n' "$enums" | grep -Fqx -- "$want"`. When grep matches it exits immediately and closes the pipe, so printf is killed by SIGPIPE (exit 141) while it still has data to write. Under `set -o pipefail` that 141 propagates as the pipeline's status, so `if ! <pipeline>` reads a preset that IS present as missing. It is a race with the pipe buffer, so it fires intermittently and mostly on the larger enums -- seen in CI on http-cache-rd, whose schema carries two 47-entry enums -- failing the "Unit & controller tests" job for unrelated PRs. Feed grep from a here-string instead of a pipe: no second process, no SIGPIPE, no pipefail interaction. Deterministic repro of the old behaviour (target at the front of a 100k-line list): the pipe form reports "missing", the here-string form finds it. Signed-off-by: Alexey Artamonov <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe preset validation script replaces a ChangesPreset validation
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This change makes preset validation reliable by avoiding false failures when grep finds a match. No merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
## What this PR does `rd-presets-check` discards `jq` errors, so malformed schema can pass the check or appear as missing presets. It now fails with the schema path and `jq` diagnostic. An absent schema or a readable schema without `resourcesPreset` is still skipped. Regression tests use real `jq` for malformed input and partial output. They also cover the canonical preset set, exact matching and the long-list case fixed by [#4204](#4204). ### Testing - `make unit-tests -j4 --output-sync=target` passed. - Nine cases in `hack/check-rd-presets_test.bats`, run with `bats` and `dash hack/cozytest.sh`. - Both read-failure cases fail against `main`. Eleven deliberate code mutations also fail the expected test. - `shellcheck hack/check-rd-presets.sh hack/check-rd-presets_test.bats`. ### Screenshots Not applicable. ### Downstream repositories - [x] No downstream repository is affected by this change No files or make targets were moved or renamed. The change is limited to the RD checker and its tests. ### Release note ```release-note fix(tests): Fail the RD preset check when a schema cannot be read, with the schema path and jq diagnostic. ```
Summary
hack/check-rd-presets.shintermittently fails the "Unit & controller tests" CI job with a falseresourcesPreset enum missing: <preset>for a preset that is actually present — most visibly onhttp-cache-rd, and on PRs that have nothing to do with that package.Root cause
The check tests each expected preset with
printf '%s\n' "$enums" | grep -Fqx -- "$want". When grep finds the preset it exits immediately and closes the pipe, soprintfis killed by SIGPIPE (exit 141) while it still has data to write. The script runs underset -o pipefail, so that 141 becomes the pipeline's status andif ! <pipeline>records a present preset as missing. It is a race with the pipe buffer, so it fires intermittently and mostly on the larger enums (http-cache-rd's schema carries two 47-entry enums). The CI log shows the tell:check-rd-presets.sh: line 39: printf: write error: Broken pipeimmediately followed byFAIL: ... resourcesPreset enum missing: s1.micro.Fix
Feed grep from a here-string instead of a pipe — no second process, no SIGPIPE, no pipefail interaction. Deterministic reproduction (target at the front of a 100k-line list, under
set -euo pipefail): theprintf | grep -Fqxform reports the target as missing; the here-string form finds it. After the changebash hack/check-rd-presets.shpasses green.Release note
Summary by CodeRabbit