Skip to content

test: Catch alert rules that break only inside vmalert - #555

Closed
andrewb3000 wants to merge 1 commit into
mainfrom
fix/513-ready-hosts-labelset
Closed

andrewb3000 wants to merge 1 commit into
mainfrom
fix/513-ready-hosts-labelset

Conversation

@andrewb3000

@andrewb3000 andrewb3000 commented Oct 27, 2026 •

Copy link
Copy Markdown

Summary

The count of ready compute hosts per cell has failed every evaluation in the deployed environment since 21 October, so the infra alerts for a cell with no ready host, or with hosts down, cannot fire there.

It broke because its fallback reads back a stored series that carries the alert evaluator's environment label, and the inline queries used to check the rule never add that label.

This adds unit tests that load every alert rule file into vmalert-tool, at the version the platform runs, with that label set, and runs them in CI whenever the alert rules change.

The fix itself landed in #549 and already runs in a test environment, and deployed environment picks it up with the next compute release.

Limits

The capacity test checks the recorded host counts that ComputeCellNoHostReady and ComputeCellHostsUnavailable read, not those alerts, which live in the infra repo.

vmalert-tool does not print a rule's evaluation error. It panics with a nil pointer dereference instead, so the test run adds a hint naming the usual cause.

The failing run against the rule from before #549 was shown locally with the v1.121.0 release binary, not by a CI run. CI only exercises the passing path.

Test plan

  • The capacity test fails with the panic hint on the rule from before fix: tighten capacity alert rules #549, fails on main with the cordon exclusion or the one-day kubelet carry removed, and passes on main
  • A broken expression in any rule file, or a rule file no test names, fails the check
  • The rule test check passes on this PR

Related to #513

@andrewb3000
andrewb3000 force-pushed the fix/513-ready-hosts-labelset branch from f3b9353 to 823a05b Compare October 27, 2026 12:00
The ready compute host count shipped broken (#513): its fallback read back
the group's own stored output, which carries vmalert's external label, and
vmalert rejected every evaluation as two series with one labelset. The rule
was checked with inline queries, which never add that label, so nothing
caught it before production.

Key features/changes:
- Add a vmalert-tool unit test for the capacity recording rules. It covers
  cells with all, some and no hosts ready, a cordoned host, and a down host
  whose kubelet series has stopped
- Add a load-only test for each other rule file, so a broken expression
  fails, and fail when any VMRule is named by no test, since vmalert-tool
  loads only the rule files a test names
- Run the tests with an external label set, at the vmalert version the
  platform runs, so a label collision fails here as it fails in vmalert
- Fail on an unreadable or multi-document manifest, a test file with no
  tests, or a yq other than mikefarah v4, rather than passing with nothing
  checked. VMRules saved as .yml are picked up too
- Run the tests and the overlay builds in CI whenever the alert component
  changes

vmalert-tool does not print a rule's evaluation error. It panics with a nil
pointer dereference in the rule's exec, because it never registers the
error counter that exec increments. The script spots that panic and prints
a hint naming the usual cause. Against the rule from before #549 the test
exits 2 on that panic; against main it passes.
@andrewb3000
andrewb3000 force-pushed the fix/513-ready-hosts-labelset branch from 823a05b to e43b160 Compare October 27, 2026 12:11
@andrewb3000
andrewb3000 deleted the fix/513-ready-hosts-labelset branch October 27, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant