-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: r/vsphere_vm_storage_policy
delete method check for use
#1863
fix: r/vsphere_vm_storage_policy
delete method check for use
#1863
Conversation
…ashicorp#1428 Modify the resourceVMStoragePolicyDelete method to check the response of pbmClient.DeleteProfile() API call for errors and re-throw them. As a result of this if a policy is in use and cannot be deleted, the destroy operation will fail and the policy will remain in the state.
r/vsphere_vm_storage_policy
not deleted after terraform destroy #1428r/vsphere_vm_storage_policy
not deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @stoyan-hristov.
Reviewed, successfully tested, and approved. 🚀
Summary of Test Results
➜ terraform destroy --auto-approve
data.vsphere_tag_category.policy_category: Reading...
data.vsphere_tag_category.policy_category: Read complete after 0s [id=urn:vmomi:InventoryServiceCategory:1fc04fac-74ad-46bf-972b-3aad24db8a66:GLOBAL]
data.vsphere_tag.policy_tag_include: Reading...
data.vsphere_tag.policy_tag_include: Read complete after 0s [id=urn:vmomi:InventoryServiceTag:72f80d4c-d33c-4993-a831-cc89290400d7:GLOBAL]
vsphere_vm_storage_policy.policy_tag_based_placement: Refreshing state... [id=e6bdc52e-ecaa-4a31-b813-a75d108e3d6f]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
- destroy
Terraform will perform the following actions:
# vsphere_vm_storage_policy.policy_tag_based_placement will be destroyed
- resource "vsphere_vm_storage_policy" "policy_tag_based_placement" {
- description = "This storage policy is managed by Terraform." -> null
- id = "e6bdc52e-ecaa-4a31-b813-a75d108e3d6f" -> null
- name = "foo-bar" -> null
- tag_rules {
- include_datastores_with_tags = true -> null
- tag_category = "foo" -> null
- tags = [
- "bar",
] -> null
}
}
Plan: 0 to add, 0 to change, 1 to destroy.
vsphere_vm_storage_policy.policy_tag_based_placement: Destroying... [id=e6bdc52e-ecaa-4a31-b813-a75d108e3d6f]
╷
│ Error: error while deleting policy with ID e6bdc52e-ecaa-4a31-b813-a75d108e3d6f Profile (pbm.profile.ProfileId) {
│ dynamicType = null,
│ dynamicProperty = null,
│ uniqueId = e6bdc52e-ecaa-4a31-b813-a75d108e3d6f
│ } is still associated with 2 entities.
r/vsphere_vm_storage_policy
not deletedr/vsphere_vm_storage_policy
delete method check for use
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Description
Modify the resourceVMStoragePolicyDelete method to check the response of pbmClient.DeleteProfile() API call for errors and re-throw them. As a result of this if a policy is in use and cannot be deleted, the destroy operation will fail and the policy will remain in the state.
Testing done:
Acceptance tests
Output from acceptance testing:
Release Note
Release note for CHANGELOG:
Bug fix:
r/vsphere_vm_storage_policy
not deleted after terraform destroy #1428References
Closes #1428