Closed bishopbm1 closed 1 month ago
Facing quite a similar issue when using customization. The key issue is, that sometimes TF is not recognizing that the VM was provisioned and customized successfully (and the behavior is quite random to me).
If it is happening, TF is still in the state "Waiting for VM customization to complete" but on vSphere I can see the event outlining that the customization has finished successfully. After 10 minutes of waiting TF will timeout (although the VM cloned and customized after less than 3 minutes).
Yes this is the exact issue we had. If you set the timeout to 0 and handle the waiting some other way (if you need to handle the waiting) it will work.
@bishopbm1 did you ever find a workaround in the last 4 years?
@bishopbm1 i am having issues reproducing this issue, I have a smaller environment though, are you asking for a wait timer to be added to the code?
I'm going to lock this issue 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 similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Terraform Version
vSphere Provider Version
Affected Resource(s)
vsphere_virtual_machine
Terraform Configuration Files
Debug Output
Terraform_Provision_Logs.zip
Expected Behavior
I would expect that Terraform waits for customization to complete and turns on VM after finishes.
Actual Behavior
This environment is very loaded and can take a while to do even simple tasks such as snapshots, etc. So as a result the Clone/Customizations/PowerOn tasks can take a while to complete. Because of this it seems that Terraform hits a race condition and just waits. Even though on the VMWare side the vm is up and has been successfully customized.
Seems as if the condition occurs on the following lines: https://github.com/terraform-providers/terraform-provider-vsphere/blob/60243ec5db6dfcd192a2a719d1be8a59aec7c791/vsphere/resource_vsphere_virtual_machine.go#L1313-L1344
I see in the uploaded soap calls that we get the system time but i do not see that it ever checks to see if the customizations are complete. I would think that there needs to be some sort of check every so often in the wait processing to see if customizations are finished or not.
Steps to Reproduce
terraform apply
Workaround
A workaround for this issue is to set the timeout to 0 then handle the wait in a different way.