Fix calculation of diskCapacityInGiB by rounding up #1397
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Invalid operation for device '0'
when cloning a virtualmachine template with a disk whose size is not an multiple of 1024^3
bytes, by ensuring that the calculated disk capacity is rounded up
rather than down.
Description
The vsphere_virtual_machine data source calculates and stores disk size in integer GiB. Unfortunately, without this patch, the calculation always rounds the size down. As a result, if the vsphere_virtual_machine resource is used to clone a template with a non-integer GiB disk, it tries to shrink the disk to the calculated, rounded-down size, resulting in the opaque error
Invalid operation for device '0'
.This PR resolves the issue by ensuring that the calculated size is always rounded up rather than down, so that, for example, a Packer-generated template with disk size 42000MiB will be cloned without error to a virtual machine with disk size 42GiB rather than 41GiB.
Acceptance tests
Output from acceptance testing:
Release Note
Release note for CHANGELOG:
References