Skip to content

Report teardown-only failures through the exit status and the log - #100

Merged
bgrewell merged 1 commit into
mainfrom
feature/teardown-only-exit
Aug 8, 2026
Merged

Report teardown-only failures through the exit status and the log#100
bgrewell merged 1 commit into
mainfrom
feature/teardown-only-exit

Conversation

@bgrewell

@bgrewell bgrewell commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Stacked on #99.

The problem

A cleanup job that cannot report its own failure is worse than no cleanup job. Two independent defects made --teardown-only exactly that:

  1. It returned nil unconditionally. A broken teardown step, or a node that would not come down, exited 0 and CI moved on with resources still allocated.
  2. Its errors bypassed the formatter. All three messages were written with fmt.Printf straight to stdout rather than through the formatter --log wraps, so a -l file contained the task lines and none of the errors.

The documented workaround was to pipe the console through tee and grep it — and that recipe was itself wrong, since a trailing grep … && exit 1 as a script's last line fails the job precisely when cleanup succeeded.

The fix

Failures are collected as the run proceeds, printed through the formatter, and summarized in an error that sets the exit status:

Error: teardown failed: 1 of 4 cleanup operations did not complete;
the first was: running teardown step "drop test network": command failed with exit code 7

Best-effort behaviour is deliberately unchanged — every teardown step, node, and platform is still attempted after an earlier failure, because leaving resources behind is worse than a partial teardown. Only the reporting changed.

Verified end to end:

Case Exit -l captures the error
Failing teardown step + failing node teardown 1 yes
Clean teardown 0 n/a

and the later steps still ran in the failing case.

The CI recipe collapses

dart -c suite.yaml --teardown-only     # non-zero if any cleanup failed

No tee, no grep, no exit-status normalisation. The docs section that explained the scraping workaround is replaced by that one line.

Verification

New controller tests assert the failing case exits non-zero, that cleanup still continues past the failure (both the later step and node teardown run), and that the errors reach the formatter rather than raw stdout — plus that a clean run still exits 0 and prints no errors. The test formatter now records PrintError calls, which is what makes the second assertion possible.

go build, go vet, gofmt, and the full suite are green; the docs site builds.

A cleanup job that cannot report its own failure is worse than no cleanup
job. --teardown-only returned nil unconditionally, so a broken teardown step
or a node that would not come down exited 0 and CI moved on with resources
still allocated.

Its three error messages were also written with fmt.Printf straight to
stdout rather than through the formatter that --log wraps, so a -l file
contained the task lines and none of the errors — the documented workaround
was to pipe the console through tee and grep it, and even that recipe was
wrong: a trailing `grep ... && exit 1` fails the job precisely when cleanup
succeeds.

Failures are now collected as the run proceeds, printed through the
formatter, and summarized in an error that sets the exit status. Best-effort
behaviour is unchanged: every teardown step, node, and platform is still
attempted after an earlier failure, since leaving resources behind is worse
than a partial teardown.

The CI recipe in the documentation collapses to running the command.
Base automatically changed from feature/check-capabilities to main August 8, 2026 15:43
@bgrewell
bgrewell merged commit ddfcff4 into main Aug 8, 2026
2 checks passed
@bgrewell
bgrewell deleted the feature/teardown-only-exit branch August 8, 2026 15:43
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