Skip to content

fix(hack): avoid a SIGPIPE false-negative in the resourcesPreset check - #4204

Merged
scooby87 merged 1 commit into
mainfrom
fix-rd-presets-sigpipe
Sep 11, 2026
Merged

scooby87 merged 1 commit into
mainfrom
fix-rd-presets-sigpipe

Conversation

@scooby87

@scooby87 scooby87 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

hack/check-rd-presets.sh intermittently fails the "Unit & controller tests" CI job with a false resourcesPreset enum missing: <preset> for a preset that is actually present — most visibly on http-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, so printf is killed by SIGPIPE (exit 141) while it still has data to write. The script runs under set -o pipefail, so that 141 becomes the pipeline's status and if ! <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 pipe immediately followed by FAIL: ... 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): the printf | grep -Fqx form reports the target as missing; the here-string form finds it. After the change bash hack/check-rd-presets.sh passes green.

Release note

NONE

Summary by CodeRabbit

  • Bug Fixes
    • Improved preset validation to prevent false errors when configured presets are present.

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]>
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1860c513-a164-42a3-9891-700f2d23aaf9

📥 Commits

Reviewing files that changed from the base of the PR and between e89617d and c2e7c86.

📒 Files selected for processing (1)
  • hack/check-rd-presets.sh

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The preset validation script replaces a printf pipeline with a here-string. This prevents pipefail from treating early grep termination as a failure.

Changes

Preset validation

Layer / File(s) Summary
Use here-string input for preset checks
hack/check-rd-presets.sh
The script passes preset data to grep through a here-string. This prevents false missing-preset failures caused by SIGPIPE under pipefail.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to c2e7c

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)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing a SIGPIPE-related false-negative in the resourcesPreset check.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-rd-presets-sigpipe

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size/XS This PR changes 0-9 lines, ignoring generated files area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review kind/bug Categorizes issue or PR as related to a bug labels Sep 10, 2026
@scooby87
scooby87 enabled auto-merge September 11, 2026 07:53
@scooby87
scooby87 merged commit 080c649 into main Sep 11, 2026
21 checks passed
@scooby87
scooby87 deleted the fix-rd-presets-sigpipe branch September 11, 2026 08:00
Aleksei Sviridkin (lexfrei) added a commit that referenced this pull request Sep 28, 2026
## 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.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review kind/bug Categorizes issue or PR as related to a bug size/XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants