ci: apply-reconcile must fail when the apply log is empty or has no recap #607

Stängd
öppnade 2026-10-08 21:12:21 +00:00 av supernaut · 0 kommentarer
Ägare

What

scripts/apply-reconcile.py is the preferred prod apply gate. It compares the tasks changed in the --check log with the apply log, by name. It parses the PLAY RECAP counts (:252-258) but never cross-checks them against the parsed changed set. The script has no test.

Why

The gate says "apply matched the dry run exactly" and returns 0 whenever it finds no changed: lines it can parse, even when the recap says tasks changed.

Failing case

  • The apply log is empty or cut off before the recap, and the check log has no changes. Both parse to zero rows. Output: apply matched the dry run exactly, rc 0.
  • A recap line says changed=1 for a host but no changed: [host] line matched. The count is ignored.
  • CHANGED_LINE and RECAP_LINE are anchored at column 0. A log written with colour (for example ANSIBLE_FORCE_COLOR=1 exported in the operator shell) does not match. The wrapper pipes through tee, so colour is off by default, but nothing guards it.

Fix

In extract_changed, strip \x1b\[[0-9;]*m per line. In cmd_reconcile, return 1 if the apply log has no recap line, or if for any host recap[h] > 0 and no (h, task) row was parsed. Add scripts/test_apply_reconcile.py with fixtures for a normal log, a coloured log, an empty log and a truncated log, and run it in CI.

Done when

  • An empty apply log fails the gate.
  • A recap with changed>0 and no parsed rows fails the gate.
  • A coloured log parses the same as a plain one.
  • The test runs in ci.yml.
## What `scripts/apply-reconcile.py` is the preferred prod apply gate. It compares the tasks changed in the `--check` log with the apply log, by name. It parses the PLAY RECAP counts (`:252-258`) but never cross-checks them against the parsed changed set. The script has no test. ## Why The gate says "apply matched the dry run exactly" and returns 0 whenever it finds no `changed:` lines it can parse, even when the recap says tasks changed. ## Failing case - The apply log is empty or cut off before the recap, and the check log has no changes. Both parse to zero rows. Output: `apply matched the dry run exactly`, rc 0. - A recap line says `changed=1` for a host but no `changed: [host]` line matched. The count is ignored. - `CHANGED_LINE` and `RECAP_LINE` are anchored at column 0. A log written with colour (for example `ANSIBLE_FORCE_COLOR=1` exported in the operator shell) does not match. The wrapper pipes through `tee`, so colour is off by default, but nothing guards it. ## Fix In `extract_changed`, strip `\x1b\[[0-9;]*m` per line. In `cmd_reconcile`, return 1 if the apply log has no recap line, or if for any host `recap[h] > 0` and no `(h, task)` row was parsed. Add `scripts/test_apply_reconcile.py` with fixtures for a normal log, a coloured log, an empty log and a truncated log, and run it in CI. ## Done when - [ ] An empty apply log fails the gate. - [ ] A recap with `changed>0` and no parsed rows fails the gate. - [ ] A coloured log parses the same as a plain one. - [ ] The test runs in `ci.yml`.
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra#607
Ingen beskrivning angiven.