Open mrchrd opened 1 year ago
Hello, mrchrd! π
Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.
If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.
Community Guidelines
Terraform
v1.3.6
Terraform Provider
v2.2.0
VMware vSphere
v7.0.3
Description
When a single Terraform module creates a
vsphere_virtual_machine
and add anorphaned_disk
(through the vSphere Container Storage Plug-in in my case), then, when the module is destroyed, it destroys theorphaned_disk
and thevsphere_virtual_machine
resource in the same operation. Since the orphaned disk is destroyed before the virtual machine, theDelete
operation does not find the disk and return acannot find disk device
error and does not destroy thevsphere_virtual_machine
resource.The error should be silently ignored if the orphaned disk is already destroyed or detached since the infrastructure is already at the desired state.
The relevant code seems to be here:
Affected Resources or Data Sources
resource/vsphere_virtual_machine
Terraform Configuration
Debug Output
Panic Output
No response
Expected Behavior
The
Delete
function should silently ignore a disk sub-resource that is not found (aka already deleted), and continue with the deletion of thevsphere_virtual_machine
resource.Actual Behavior
The
Delete
function returns acannot find disk device
error and thevsphere_virtual_machine
resource is not destroyed.Steps to Reproduce
This reproduces the same behavior as if a module were creating a virtual machine and attach a new disk using the vSphere Container Storage Plug-in, and then destroy them:
terraform apply
govc vm.disk.create -vm "${name}" "${name}/disk1" -size 1G
terraform plan -destroy -out destroy.plan
govc device.remove -vm "${name}" disk-1000-1
terraform apply destroy.plan
Environment Details
No response
Screenshots
No response
References
No response