Add --force flag to rad resource delete and rad app delete#11625
Add --force flag to rad resource delete and rad app delete#11625willdavsmith wants to merge 12 commits intomainfrom
Conversation
Add a --force option to both 'rad resource delete' and 'rad app delete' commands that allows users to delete resources stuck in non-terminal provisioning states (e.g., Updating, Accepted). Server-side: DefaultAsyncDelete reads a 'force' query parameter and skips the provisioning state conflict check when force=true, while still validating ETags and running delete filters. Client-side: A forceDeletePolicy pipeline policy injects force=true as a query parameter when the force option is set. CLI: Both commands accept --force, display a warning about potential orphaned external resources, and pass the flag through to the API.
Add a --force option to both 'rad resource delete' and 'rad app delete' commands that allows users to delete resources stuck in non-terminal provisioning states (e.g., Updating, Accepted). Server-side: DefaultAsyncDelete reads a 'force' query parameter and skips the provisioning state conflict check when force=true, while still validating ETags and running delete filters. Client-side: A forceDeletePolicy pipeline policy injects force=true as a query parameter when the force option is set. CLI: Both commands accept --force, display a warning about potential orphaned external resources, and pass the flag through to the API. Signed-off-by: willdavsmith <willdavsmith@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds a --force deletion capability across Radius CLI, client, and server to allow deleting resources stuck in non-terminal provisioning states (avoiding 409 Conflict), while still honoring ETag validation and delete filters.
Changes:
- CLI: add
--forcetorad resource deleteandrad app delete, including user-facing warnings. - CLI client: plumb a
forceboolean through delete APIs and injectforce=truevia an Azure SDK per-call pipeline policy (avoids modifying generated SDK signatures). - Server:
DefaultAsyncDeleterecognizesforce=trueand skips the non-terminal provisioning-state conflict check; tests extended accordingly.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/validation/shared.go | Updates helper to call DeleteResource(..., false) with new signature. |
| test/functional-portable/cli/noncloud/cli_test.go | Updates functional tests for new DeleteResource(..., force) signature. |
| pkg/cli/delete/delete.go | Passes Force through to DeleteApplication(...). |
| pkg/cli/delete/delete_test.go | Updates mocks for new DeleteApplication(..., force) signature. |
| pkg/cli/cmd/resource/delete/delete.go | Adds --force, warning text, and passes force to management client. |
| pkg/cli/cmd/commonflags/flags.go | Introduces shared AddForceFlag. |
| pkg/cli/cmd/app/delete/delete.go | Adds --force, warning text, and passes force into delete progress flow. |
| pkg/cli/clients/mock_applicationsclient.go | Regenerates mocks for updated delete method signatures. |
| pkg/cli/clients/management.go | Adds force plumbing and forceDeletePolicy for query injection on generic deletes. |
| pkg/cli/clients/management_test.go | Updates tests for new signatures (no force-specific assertions added). |
| pkg/cli/clients/clients.go | Extends interfaces/options to include Force. |
| pkg/armrpc/frontend/defaultoperation/defaultasyncdelete.go | Implements force=true behavior in async delete. |
| pkg/armrpc/frontend/defaultoperation/defaultasyncdelete_test.go | Adds/extends tests for force-delete paths and filter behavior. |
- Fix DeleteApplication to also inject force=true when deleting the application resource itself (not just child resources) - Add Test_ForceDeletePolicy verifying the pipeline policy correctly injects the force=true query parameter
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #11625 +/- ##
==========================================
+ Coverage 51.40% 51.49% +0.08%
==========================================
Files 699 699
Lines 44036 44085 +49
==========================================
+ Hits 22638 22700 +62
+ Misses 19244 19225 -19
- Partials 2154 2160 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Now that DeleteResource supports force=true, the retry-with-backoff loop for 409 Conflict errors in DeleteRPResourceSilent is unnecessary. Use force=true directly to handle resources stuck in non-terminal provisioning states during test cleanup.
- Move force-delete warning before the confirmation prompt in both rad resource delete and rad app delete so users see the risk before confirming. - Add test case for force-delete with incorrect ETag to verify 412 Precondition Failed is returned.
Add tests covering the --force flag in rad resource delete and rad app delete to improve patch coverage for the force-delete code paths.
- Move force-delete warning outside the confirmation prompt block so it is shown even with --yes --force. - Update doc comments on createApplicationClient and getGenericClient to clarify that force policy injection only applies when no factory is configured.
The policy was applying force=true to all requests including poller GETs. Now it only modifies DELETE requests and skips if force is already set.
|
|
||
| if err != nil { | ||
| return nil, err | ||
| clientOptions := *amc.ClientOptions |
There was a problem hiding this comment.
are these lines of code doing the same as ~ln1211-ln1220? should it be pulled out into a helper funciton?
There was a problem hiding this comment.
Good catch — they were doing the same thing. Extracted into a withForceDeletePolicy helper in bb897a6 so both createApplicationClient and getGenericClient share the same logic for appending the per-call policy.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Description
Add a
--forceoption to bothrad resource deleteandrad app deletecommands that allows users to delete resources stuck in non-terminal provisioning states (e.g., "Updating", "Accepted") which otherwise return a 409 Conflict.Server-side:
DefaultAsyncDeletereads aforce=truequery parameter and skips the provisioning state conflict check, while still validating ETags and running delete filters.Client-side: A
forceDeletePolicypipeline policy injectsforce=trueas a query parameter when the force option is set, avoiding changes to the auto-generated SDK.CLI: Both commands accept
--force, display a warning about potential orphaned external resources, and pass the flag through to the API.Concurrency safety
When force-deleting a resource with an in-flight operation, the existing safety nets handle the race:
ErrNotFoundwhen the resource is deleted out from under itThe residual risk (orphaned external resources from a concurrent update) is the standard
--forcecontract — the user acknowledges this via the warning message.Type of change
Fixes: #11147
Fixes: #3972
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: