Fix catalog-item instance delete when placement run is already absent - #84
gciavarrini wants to merge 1 commit into
Conversation
Treat placement manager 404 as success during catalog-item instance deletion so the DB record is removed and the parent catalog item can be deleted afterwards. Assisted-By: Claude (Anthropic) Signed-off-by: Gloria Ciavarrini <gciavarrini@redhat.com>
PR Summary by QodoAllow instance deletion when its placement run is already absent
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Remote deletes still fail for absent runs
|
| // policy-rejected/provider-error/policy-dependency (406/422/424) | ||
| // from a generic placement failure, matching create/rehydrate. | ||
| return mapPlacementError(err, ErrPlacementManagerDeleteFailed) | ||
| if isPlacementNotFound(err) { |
There was a problem hiding this comment.
1. Remote deletes still fail for absent runs 🐞 Bug ≡ Correctness
isPlacementNotFound accepts only a PlacementError, but the remote client's DeleteRun returns a plain formatted error for HTTP 404. When a placement manager URL selects that client, instance deletion returns a placement failure before removing the catalog record, leaving the parent deletion blocked.
Agent Prompt
## Issue description
The remote placement client's `DeleteRun` turns HTTP 404 into an untyped error, so the new absent-run branch cannot recognize it.
## Fix Focus Areas
- internal/catalog/placement/client.go[173-181]
- internal/catalog/service/catalog_item_instance.go[272-282]
- internal/catalog/placement/client_test.go[187-201]
## Recommended Fix
Return a `PlacementError` containing the HTTP status and response body for non-2xx remote delete responses. Test that a remote 404 is recognized by catalog instance deletion and permits removal of the stored instance.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
When a placement run is removed before its catalog-item instance is deleted, the delete call fails with HTTP 500 because the placement manager returns 404 and the service treats it as a hard error.
The DB record stays, and the parent catalog item cannot be deleted (HTTP 409).
Treat a placement 404 during instance delete as success (the run is already gone), removes the DB record, and unblocks parent deletion.
Fixes
FLPATH-4922