-
Notifications
You must be signed in to change notification settings - Fork 452
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
Updates of a vsphere_virtual_machine may always require the resource to be in a powered off state due to SetHardwareVersion #1149
Comments
So the issue seems to actually be here. Changing the hardware version requires the machine to be powered off. I'm pretty sure we'll need to explicitly check the version and compare if the update is actually changing the version instead of retaining it. vsphere/resource_vsphere_virtual_machine.go:1666
|
I'm patching it right now and will let y'all know if this resolves it. |
Okay, so what's happening is when SetHardwareVersion fetches the properties to compare the HwVersion if it changes, the properties it gets back has HwVersion set to the following.
Let me confirm with the docs on why the HwVersion is unset here. |
Okay. So it seems that all our VMs have this field unset (both powered on and powered off). I reported this issue 4 days ago, and we updated from 6.5 to 6.7 on Tuesday so I'm not sure whether this is the same on versions earlier than 6.5. Nonetheless, the JSON that vSphere gives back is the following. I'm not sure which HwVersion is being checked, but I imagine it's
|
So I believe govmomi has these fields as optional (omitempty tag), but could be entirely mistaken here.
However, if you query the
This corresponds to the docs for So these attributes are using |
Apparently a
|
Updated title with a more general one as I believe this affects all updates of a |
PR #1159 fixes this. |
Yep. Got it. |
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
Terraform v0.12.29
vSphere Provider Version
v1.21.1
Affected Resource(s)
I think it only affects this one:
vsphere_virtual_machine
Terraform Configuration Files
Could look something like the following. The idea is that you deploy once, then modify "my_configuration" to point to a different datastore. This should perform an update.
Debug Output
Relevant logs follow, but they don't seem too useful. Relevant code is at
vsphere/resource_vsphere_virtual_machine.go
whereresourceVSphereVirtualMachineUpdate
is defined. It seems that the logic is explicitly checking what's being updated to set a "changed" flag, and then using that to determine whether to power off the machine. The datastore does not seem to be being checked.Panic Output
No panic.
Expected Behavior
I expect it to move the machine to a different datastore, or at very least expose some way that I could influence the powerState for the vsphere_virtual_machine so that I can move it to a different datastore. It seems that govmomi exposes controlling power for machines with the PowerOn and PowerOff methods.
Actual Behavior
Instead of powering off the virtual machine according to the documentation which references failure during updating:
I get the following error. Is there some way I can shutdown the virtual machine with the "terraform-provider-vsphere" plugin?
Steps to Reproduce
terraform apply
to first deploy a box.terraform apply
, confirm that it's only making a change to the datastore, and then apply it.Important Factoids
This is just for an internal tutorial I'm trying to write to promote usage of tf on our vSphere instance.
References
None.
Community Note
The text was updated successfully, but these errors were encountered: