Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix stuck portable resource deletion bug (#6247)
# Description Adding deletion logic to address #6040. The general logic is that if we have an error before the Recipe is deployed, we don't proceed with engine/driver deletion. If there was an error during execution, we proceed with engine/driver deletion to take care of any output resources that may have been deployed. ## Type of change <!-- Please select **one** of the following options that describes your change and delete the others. Clearly identifying the type of change you are making will help us review your PR faster, and is used in authoring release notes. If you are making a bug fix or functionality change to Radius and do not have an associated issue link please create one now. --> - This pull request fixes a bug in Radius and has an approved issue #6040 <!-- Please update the following to link the associated issue. This is required for some kinds of changes (see above). --> Fixes: #6040 ## Auto-generated summary <!-- GitHub Copilot for docs will auto-generate a summary of the PR --> <!-- copilot:all --> ### <samp>🤖 Generated by Copilot at c552dea</samp> ### Summary 🚀🛠️🧪 <!-- 1. 🚀 - This emoji represents the addition of new features or functionality, such as the `SetDeploymentStatus` methods for different resource types, the generic type parameters for the `NewCreateOrUpdateResource` and `NewDeleteResource` functions, and the new field and type for tracking the deployment status of resource recipes. 2. 🛠️ - This emoji represents the improvement or refactoring of existing code, such as the renaming of receiver names, the simplification of type assertions, the error handling for recipe definitions and executions, and the use of the `portableresources` package to standardize the error statuses. 3. 🧪 - This emoji represents the update or enhancement of test cases, such as the alignment of the test code with the actual usage of the `Extender` type, the handling of the `ErrRecipeNotFound` error, and the matching of the expected errors from the `driver` package. --> Added and updated methods to set and save the deployment status of portable resources based on the recipe execution result. Improved error handling and reporting for recipe drivers and config loaders. Renamed some receiver names for consistency and readability. Updated test cases to match the expected errors and statuses. > _To manage resources with recipes_ > _We added some methods and types, please_ > _They update the status_ > _And handle the errors_ > _With `portableresources` and `drivers`_ ### Walkthrough * Add `SetDeploymentStatus` method to various resource types to update deployment status based on recipe execution result ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b35b07eee0834a6f13240f9f22b2a09d8a933298507c72f37ff5792ba830fd02L62-R73), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-a74b5d21cf74e51c5ab93a6f4634a606a4f869aa1b9a279fb25df2fdcc386d2dR65-R69), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-e58a6737964c53219141f95631bcc9c8e7bb532d131b03919fd9593cf29b6dbaL70-R79), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-fc58b9bab039ec2431cb779e41394e5f95a51cb7f415b0da40c630f441810f3aR65-R69), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b463cddd0e8f4aa4356725d5f2eb81f215216544149ac54b74a0a910868665a1R127-R131), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-0edf5ad38ca1c7194bb66f75828b10cd79c512f9fdabea5eb00db52e016a8f39R103-R107), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-79d6e8286f9b10662ae6ec8e91f5c32a7d53fcc762f922c4452130b1fe0005dbL66-R74), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b5a5c7f766f17b812eb1e5bd1815303ade4f0486d243708a526832a65bbed011R83-R87)) * Change receiver names of `ResourceTypeName` and other methods for various resource types to `r` for consistency ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b35b07eee0834a6f13240f9f22b2a09d8a933298507c72f37ff5792ba830fd02L56-R56), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-a74b5d21cf74e51c5ab93a6f4634a606a4f869aa1b9a279fb25df2fdcc386d2dL53-R53), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-e58a6737964c53219141f95631bcc9c8e7bb532d131b03919fd9593cf29b6dbaL53-R61), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-fc58b9bab039ec2431cb779e41394e5f95a51cb7f415b0da40c630f441810f3aL53-R53), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b463cddd0e8f4aa4356725d5f2eb81f215216544149ac54b74a0a910868665a1L73-R82), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b463cddd0e8f4aa4356725d5f2eb81f215216544149ac54b74a0a910868665a1L133-R138), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-0edf5ad38ca1c7194bb66f75828b10cd79c512f9fdabea5eb00db52e016a8f39L57-R57), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-0edf5ad38ca1c7194bb66f75828b10cd79c512f9fdabea5eb00db52e016a8f39L63-R67), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-0edf5ad38ca1c7194bb66f75828b10cd79c512f9fdabea5eb00db52e016a8f39L77-R83), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-2f8e234f7e5ff8a646351b71cfa4333f1d1f935b4116ec32bcf6e8b6d117583eL57-R65), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-2f8e234f7e5ff8a646351b71cfa4333f1d1f935b4116ec32bcf6e8b6d117583eL97-R103)) * Change `NewCreateOrUpdateResource` and `NewDeleteResource` functions to use generic type parameters instead of empty interface ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1dfecb9519c9002f569daea7fb61bbb0b1f22e34d49ac2d03eeb3bc64e858c8fL224-R224), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1dfecb9519c9002f569daea7fb61bbb0b1f22e34d49ac2d03eeb3bc64e858c8fL234-R234), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1dfecb9519c9002f569daea7fb61bbb0b1f22e34d49ac2d03eeb3bc64e858c8fL241-R241)) * Change `executeRecipeIfNeeded` method to set and save deployment status of resource based on recipe error code and status ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-88040b9959d0c406cb8ed95caa785345085b114078658de636164a546f910749L79-R96), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-88040b9959d0c406cb8ed95caa785345085b114078658de636164a546f910749L99-R119), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-88040b9959d0c406cb8ed95caa785345085b114078658de636164a546f910749L123-R139)) * Change `Run` method to skip recipe deletion if deployment status is `RecipeSetupError` ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-c6fc204032902b38f97dc71fe64ce145d1f851419f4eef7682a2d62183172a03L76-R81)) * Add `SetDeploymentStatus` method to `RecipeDataModel` interface ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-fa271c3c303372742608e60b5de526ef1d2f46f492f6e33a0e7003c6b8ad8b25R31-R32)) * Add `DeploymentStatus` field to `ResourceRecipe` type ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-a84c1408454dbdd6e92b77d98a50ce8954bc2477ffbef4eabd32d9f1d587e743R83-R84)) * Add `RecipeDeploymentStatus` type and constants to `portableresources` package ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-a84c1408454dbdd6e92b77d98a50ce8954bc2477ffbef4eabd32d9f1d587e743R131-R141)) * Change `getRecipeDefinition` function to use `NewRecipeError` function with `RecipeSetupError` status ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-0b45f6a08490c2a47c6ead052f97e5b5be965617c8ab927d9b0a297088a92a6eL127-R141)) * Change `Execute` and `Delete` methods of `Bicep` and `Terraform` drivers to use `NewRecipeError` function with appropriate status ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-f12e37706fa75e9e04b8dfa01a45cf9bf2a0463e1962605b2420d0cb343922a0L82-R83), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-f12e37706fa75e9e04b8dfa01a45cf9bf2a0463e1962605b2420d0cb343922a0L90-R91), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-f12e37706fa75e9e04b8dfa01a45cf9bf2a0463e1962605b2420d0cb343922a0L101-R102), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-f12e37706fa75e9e04b8dfa01a45cf9bf2a0463e1962605b2420d0cb343922a0L129-R140), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-f12e37706fa75e9e04b8dfa01a45cf9bf2a0463e1962605b2420d0cb343922a0L151-R152), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-f12e37706fa75e9e04b8dfa01a45cf9bf2a0463e1962605b2420d0cb343922a0L164-R165), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-f12e37706fa75e9e04b8dfa01a45cf9bf2a0463e1962605b2420d0cb343922a0L179-R180), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1b98bc9b02b96687752860c11c68d87d99ad99f24ecdfc5497fda6823abc0612L72-R73), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1b98bc9b02b96687752860c11c68d87d99ad99f24ecdfc5497fda6823abc0612L87-R93), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1b98bc9b02b96687752860c11c68d87d99ad99f24ecdfc5497fda6823abc0612L104-R105), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1b98bc9b02b96687752860c11c68d87d99ad99f24ecdfc5497fda6823abc0612L119-R120), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1b98bc9b02b96687752860c11c68d87d99ad99f24ecdfc5497fda6823abc0612L183-R184), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1b98bc9b02b96687752860c11c68d87d99ad99f24ecdfc5497fda6823abc0612L197-R198)) * Change `GetRecipeMetadata` method of `Terraform` driver to use `NewRecipeError` function with empty status ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1b98bc9b02b96687752860c11c68d87d99ad99f24ecdfc5497fda6823abc0612L183-R184), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-1b98bc9b02b96687752860c11c68d87d99ad99f24ecdfc5497fda6823abc0612L197-R198)) * Change `RecipeError` type to include `DeploymentStatus` field ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-f58db8b718c75e0a6b877b5750d8613d7be5aa1a4aafff11b861caeac4aff66dL20-R25)) * Change `NewRecipeError` function to accept `DeploymentStatus` parameter ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-f58db8b718c75e0a6b877b5750d8613d7be5aa1a4aafff11b861caeac4aff66dL37-R43)) * Change test cases to use `Applications.Core/extenders` resource type instead of `Applications.Test/testResources` type ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b5a5c7f766f17b812eb1e5bd1815303ade4f0486d243708a526832a65bbed011L44-R47), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b5a5c7f766f17b812eb1e5bd1815303ade4f0486d243708a526832a65bbed011L125-R132), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b5a5c7f766f17b812eb1e5bd1815303ade4f0486d243708a526832a65bbed011L273-R278), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b5a5c7f766f17b812eb1e5bd1815303ade4f0486d243708a526832a65bbed011L281-R286)) * Change test cases to expect `RecipeSetupError` or `ExecutionError` status in error details ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-b5a5c7f766f17b812eb1e5bd1815303ade4f0486d243708a526832a65bbed011L202-R212), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-a0a208a111e71713a21b404fdb3b31fd13f668e5716ab4331584027cc3d98debR477), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-ae6e6fdc3b9219f2f1b2dbfd1cfaff3ff2d941a2a4d58fd33b910bd1fbf31e92R154), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-ae6e6fdc3b9219f2f1b2dbfd1cfaff3ff2d941a2a4d58fd33b910bd1fbf31e92R209), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-ae6e6fdc3b9219f2f1b2dbfd1cfaff3ff2d941a2a4d58fd33b910bd1fbf31e92R236)) * Change test case to use `RecipeError` type with `RecipeGetMetadataFailed` code and empty status ([link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-ae6e6fdc3b9219f2f1b2dbfd1cfaff3ff2d941a2a4d58fd33b910bd1fbf31e92L382-R391), [link](https://github.com/radius-project/radius/pull/6247/files?diff=unified&w=0#diff-ae6e6fdc3b9219f2f1b2dbfd1cfaff3ff2d941a2a4d58fd33b910bd1fbf31e92L390-R398))
- Loading branch information