feat(project-cleanup): classify delete outcomes in four categories - #2
Merged
Conversation
…/blocked/failed)
`project cleanup` reported every non-2xx as a red ✗, which conflated
three very different situations: resource already deleted by a cascade
(volumes whose server was just removed), dependency conflict (router
with attached ports), and actual failures. On a typical run with 62
resources the output showed 31 red lines even when the delete was
functionally idempotent.
Introduce an `Outcome` enum ({SUCCESS, ALREADY_GONE, BLOCKED, FAILED})
and `_classify_api_error` that maps status code → outcome: 404 becomes
ALREADY_GONE (treated as an idempotent success), 409 becomes BLOCKED,
other HTTP / transport errors stay as FAILED.
Per-line markers now use distinct symbols and colours (`✓` green,
`~` cyan, `⊘` yellow, `✗` red) and the trailing summary reports every
category:
23 deleted · 15 already gone · 2 blocked · 1 failed (of 41)
Exit code is unchanged on purpose — scripts relying on the current
exit-0-always behaviour keep working, and changing that can be done in
a follow-up once the outcome categories are in place.
kallioli
force-pushed
the
feat/cleanup-categorize-output
branch
from
April 23, 2026 06:57
cc005f3 to
9105347
Compare
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The run shown in the previous PR produced 62 delete attempts, of which:
delete_on_termination=True),detachingstate (400 "status must be available"),Historically every non-2xx was shown as a red
✗. Operators couldn't tell at a glance whether the cleanup was functionally successful, partially blocked, or actually broken — everything looked like failure.Changes
Outcomeenum:SUCCESS,ALREADY_GONE,BLOCKED,FAILED._delete_onenow returns anOutcomeinstead of abool, and classifiesAPIErrorbystatus_code:404→ALREADY_GONE(idempotent success — a cascade already removed the resource),409→BLOCKED(dependency conflict, typically retryable or fixable by re-ordering),400,500, transport errors, unexpected exceptions) →FAILED.✓green —SUCCESS~cyan with(already gone)—ALREADY_GONE⊘yellow —BLOCKED✗red —FAILEDX/Y deletedcounter with all four buckets:_delete_onepaths, and an end-to-end Click test asserting the four-bucket summary.Behaviour unchanged
orca project cleanup --yesin a pipeline. Wiring a non-zero exit onFAILED > 0can be a follow-up once users have adapted to the new categories.Tests
ruff check .mypypytest— 2291 passedRisks
APIErrorexceptions (library bugs, unexpectedKeyError, …) still fall intoFAILED, as before. This preserves the blast-radius scope of the classification to known HTTP semantics.~,⊘) are stable across the terminals orca already supports (rich handles fallback); no regression observed on the existing rich output tests.