Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

r/virtual_machine: Address vCenter upgrade issues #405

Merged
merged 3 commits into from
Feb 26, 2018

Conversation

vancluever
Copy link
Contributor

A couple of issues come up when vCenter is upgraded:

  • First off, disk capacityInBytes values for virtual machine disk devices are cleared. This is a value we rely on to set the capacity of a disk, so a fallback to capacityInKB is necessary. This is specifically important for templates, as while VMs will be powered on and this value will be populated again, more than likely templates will remain off after the upgrade.
  • Also post-upgrade, the VM hardware version of an existing virtual machine will not have been updated (this would need to be changed manually), hence disk_sharing will be unset and unusable. However, this value will now be read in by Terraform due to the upgraded vCenter, albeit with a blank value, and will trigger a diff that will ultimately result in an error. Hence, we skip setting the sharing value if it is blank.

Note that the second issue presents another problem that is not fixed by this PR, namely that if only vCenter is upgraded, and the hypervisors are not, more than likely deploying VMs using Terraform will fail until VMs can be deployed using a hardware version that supports disk sharing. This won't be fixed until we have some awareness around VM hardware versions, which is currently not the case.

Fixes #403. Possibly helps with #402 as well but would remain to be seen.

Under certain situations, namely vCenter upgrades, the CapacityInBytes
field for virtual disks gets cleared,  which will cause issues fetching
settings for virtual disks on templates and virtual machines
post-upgrade.

This updates the virtual disk logic for both resources and data sources
so that if the value in CapacityInBytes is missing (read: less than 1),
we fall back to CapacityInKB, which will still be populated.
This is another post-upgrade thing. While vCenter will be upgraded, VM
hardware versions may remain at specific versions, especially if the
underlying hypervisors have not been upgraded yet. In this situation,
disk sharing will be an unset value and setting it will yield an error,
hence we skip setting it so that it does not create a diff.

This kind of highlights the need for us to be aware of the VM hardware
version in the future, in addition to the specific version of vCenter
the endpoint is on.
@vancluever vancluever added the bug Type: Bug label Feb 17, 2018
@vancluever vancluever requested a review from a team February 17, 2018 00:29
@vancluever
Copy link
Contributor Author

Added tests for diskCapacityInGiB:

=== RUN   TestDiskCapacityInGiB
=== RUN   TestDiskCapacityInGiB/capacityInBytes
=== RUN   TestDiskCapacityInGiB/capacityInKB
2018/02/26 08:12:18 [DEBUG] diskCapacityInGiB: capacityInBytes missing for for disk-0-0, falling back to capacityInKB
--- PASS: TestDiskCapacityInGiB (0.00s)
    --- PASS: TestDiskCapacityInGiB/capacityInBytes (0.00s)
    --- PASS: TestDiskCapacityInGiB/capacityInKB (0.00s)

@vancluever
Copy link
Contributor Author

Thanks @paultyng!

@vancluever vancluever merged commit 2cee925 into master Feb 26, 2018
@vancluever vancluever deleted the b-vcenter-upgrade branch March 31, 2018 17:41
@ghost ghost locked and limited conversation to collaborators Apr 19, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vsphere_virtual_machine.vm disk.size got 0
2 participants