Add --force flag to rad resource delete and rad app delete#11625
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.41% 51.45% +0.04%
==========================================
Files 716 716
Lines 45106 45155 +49
==========================================
+ Hits 23191 23235 +44
+ Misses 19719 19710 -9
- Partials 2196 2210 +14 ☔ 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 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.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
Rebase needed. Will there be another PR for updating docs eg. link |
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: