Skip to content

fix(ci): stop check-rd-presets reporting present presets as missing - #4194

Draft
Andrei Kvapil (kvaps) wants to merge 1 commit into
mainfrom
fix/rd-presets-broken-pipe
Draft

Andrei Kvapil (kvaps) wants to merge 1 commit into
mainfrom
fix/rd-presets-broken-pipe

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

What this PR does

hack/check-rd-presets.sh sometimes reports a preset as missing when it is in the file. Seen on #4185:

hack/check-rd-presets.sh: line 39: printf: write error: Broken pipe
FAIL: packages/system/mariadb-rd/cozyrds/mariadb.yaml resourcesPreset enum missing: c1.small

c1.small is in that file, and the script passes when I run it on the same head.

The check was printf '%s\n' "$enums" | grep -Fqx -- "$want" in a script with set -o pipefail. grep -q exits on the first match and closes the pipe while printf is still writing, printf fails with EPIPE, pipefail makes the pipeline non-zero, and ! reads that as not found. So a preset gets reported missing because it matched first. It is a race, so it hits under make -j4 in CI and not on a laptop.

It costs more than a red tick. Unit & controller tests is in needs for finalize, finalize gates e2e, so the false failure skips e2e and e2e-report posts the required E2E Tests context as failed. #4185, #4138 and #3539 are red this way right now. #4109, #4097, #3802 and #3594 are not.

Fix is a here-string instead of the pipe. This is the only script under hack/ with pipefail and | grep -q.

hack/check-rd-presets.bats covers it, picked up by the hack/*.bats glob in Makefile:161. It pins the two outcomes the check owes, a complete enum passing and an incomplete one failing with the missing value named. It does not try to win the race: a test that only reddens when the scheduler cooperates is the flaky kind this repo does not add, and the CI log in #4178 is the evidence for the bug. The fixture is written with jq alone so it does not depend on which yq dialect is installed, and it makes its temp dir in the test body because hack/cozytest.sh knows @test and nothing else.

shellcheck is clean and the check still passes on the tree.

Refs #4178

Screenshots

Not a UI change.

Downstream repositories

Nothing under packages/, no API type, no values schema, no release asset, no Talos version. One CI check script edited in place and one test file added next to it. Nothing moved or renamed, and bats-unit-tests already globbed hack/*.bats.

Release note

NONE

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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 area/ci Issues or PRs related to CI workflows, GitHub Actions, automation kind/bug Categorizes issue or PR as related to a bug size/M This PR changes 30-99 lines, ignoring generated files labels Sep 10, 2026
@lexfrei

Copy link
Copy Markdown
Contributor

The red is the harness, not the fix. make bats-unit-tests runs every hack/*.bats through hack/cozytest.sh, and that runner has no setup/teardown. Its own comment says so: "there are no bats setup/teardown directives here, this runner only knows test + bash". So setup() never runs, TMP is unset under set -u, and the file dies before it reaches an assertion:

hack/cozytest.sh: 41: TMP: parameter not set
jq: error: writing output failed: Broken pipe
make: *** [Makefile:191: bats-unit-check-rd-presets] Error 1

skip is missing there too, and teardown() never runs, so the temp dirs leak. Creating TMP inside each @test body is enough to get past it.

#4191 rewrites the same membership check to a here-string, so whichever of the two lands second conflicts on that line. It also replaces the printf | jq above the loop, which this one leaves alone, and it has no long-enum reproducer, which is the part this one has. One PR carrying both would keep everything.

The membership check piped printf into `grep -Fqx` under `set -o pipefail`.
`grep -q` exits on its first match, which can close the pipe while printf is
still in write(2); printf then fails with EPIPE, pipefail makes the pipeline
non-zero, and the negation reads that as "not found". A preset was therefore
reported missing precisely because it matched first.

It is a scheduling race, so it fired under `make -j4` in CI and not on an idle
machine. The cost was not cosmetic: `Unit & controller tests` gates `finalize`,
which gates `e2e`, so a false failure here skipped e2e and turned the required
`E2E Tests` context red, blocking merges on unrelated pull requests.

Feed grep from a here-string instead. No pipeline, nothing for pipefail to
judge, no writer to receive EPIPE. This is the only script under hack/ that
combined pipefail with a `| grep -q`.

The tests pin the two outcomes the check owes, a complete enum passing and an
incomplete one failing with the missing value named, rather than trying to win
the race: a test that only reddens when the scheduler cooperates is the flaky
kind this repo does not add. The fixture is written with jq alone so it does
not depend on which yq dialect is installed, and it creates its temp dir in the
test body because hack/cozytest.sh knows @test and nothing else.

Refs #4193

Signed-off-by: Andrei Kvapil <[email protected]>
@lexfrei

Copy link
Copy Markdown
Contributor

#4204 landed the same here-string, so the script side is already on main. What is left here is the bats file, and #4191 carries one too. Probably this can be closed once either of them is rebased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci Issues or PRs related to CI workflows, GitHub Actions, automation kind/bug Categorizes issue or PR as related to a bug size/M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants