Skip to content

[Cross Port] Fix ovf disk bugs#1521

Open
faisalabujabal wants to merge 7 commits intovmware-tanzu:release/vc-9.1.0from
faisalabujabal:fix/ovf-disk-bugs
Open

[Cross Port] Fix ovf disk bugs#1521
faisalabujabal wants to merge 7 commits intovmware-tanzu:release/vc-9.1.0from
faisalabujabal:fix/ovf-disk-bugs

Conversation

@faisalabujabal
Copy link
Contributor

What does this PR do, and why is it needed?

Which issue(s) is/are addressed by this PR? (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

Fixes #

Are there any special notes for your reviewer:

Please add a release note if necessary:


abaruni and others added 7 commits March 17, 2026 00:58
…mware-tanzu#1482)

When reconciling VMI status.disks we should consider, when present,
the DeploymentOptionSection and the default configuration.

This PR updates UpdateVmiWithOvfEnvelope() to:
1. Check for the presence of the DeploymentOptionSection
2. If present,
	- check for a confugration marked as default
	- if not configuration is marked explicitly as default, use the first configuration item
3. When populating status.disks, only consider those Items in VirtualHardware which
	- specify the default configuration via Item.Configuration, and
	- specify no configuration key via Item.Configuration, and therefore, apply to all configuation

If no DeploymentOptionSection is present, then we consider all Items in VirtualHardware
as is currently done.
…-tanzu#1509)

As of now, if the underlying datastore supports both 4kn and 512n
logical sector sizes, then we end up favoring the 4kn size.  The
vSphere API docs mention that we should be picking 512n, so do that
instead.
This patch allows images with no disks to bypass the quota check.
This patch supports fast-deploy with disks not backed by files in
the OVF.
This patch adds VM deploy tests using stock, VMware images.
This patch udpates how VMI status information is realized from OVFS.
The OVF is first converted to a ConfigSpec in order to benefit from
GoVmomi's ability to manage deployment configs and virtual system
collections.
When populating a VMI status.disk, we may encounter disks which have
duplicate names. For example

```
...
  <DiskSection>
    <Info>Virtual disk information</Info>
    <Disk ovf:capacity="107373568" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" />
    <Disk ovf:capacity="107373568" ovf:diskId="vmdisk2" ovf:fileRef="file2" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" />
  </DiskSection>
	...
    <VirtualHardwareSection>
	...
      <Item>
        <rasd:AddressOnParent>0</rasd:AddressOnParent>
        <rasd:ElementName>Hard disk 1</rasd:ElementName>
        <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
        <rasd:InstanceID>8</rasd:InstanceID>
        <rasd:Parent>3</rasd:Parent>
        <rasd:ResourceType>17</rasd:ResourceType>
      </Item>
      <Item>
        <rasd:AddressOnParent>1</rasd:AddressOnParent>
        <rasd:ElementName>Hard disk 1</rasd:ElementName>
        <rasd:HostResource>ovf:/disk/vmdisk2</rasd:HostResource>
        <rasd:InstanceID>9</rasd:InstanceID>
        <rasd:Parent>3</rasd:Parent>
        <rasd:ResourceType>17</rasd:ResourceType>
      </Item>
	...
    </VirtualHardwareSection>
...
```

or

```
...
  <DiskSection>
    <Info>Virtual disk information</Info>
    <Disk ovf:capacity="107373568" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" />
  </DiskSection>
	...
    <VirtualHardwareSection>
	...
      <Item>
        <rasd:AddressOnParent>0</rasd:AddressOnParent>
        <rasd:ElementName>Hard disk 1</rasd:ElementName>
        <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
        <rasd:InstanceID>8</rasd:InstanceID>
        <rasd:Parent>3</rasd:Parent>
        <rasd:ResourceType>17</rasd:ResourceType>
      </Item>
      <Item>
        <rasd:AddressOnParent>1</rasd:AddressOnParent>
        <rasd:ElementName>Hard disk 1</rasd:ElementName>
        <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
        <rasd:InstanceID>9</rasd:InstanceID>
        <rasd:Parent>3</rasd:Parent>
        <rasd:ResourceType>17</rasd:ResourceType>
      </Item>
	...
    </VirtualHardwareSection>
...
```

are valid OVF configurations, but will cause a failure when patching the VMI status. This is because both disks in both
scenarios here have identical names, `Hard disk 1`. Because `status.Disks` is defined as

```
	// +optional
	// +listType=map
	// +listMapKey=name

	// Disks describes the observed disk information for this image.
	Disks []VirtualMachineImageDiskInfo `json:"disks,omitempty"`
```

the patch will fail due to these duplicate keys.

This PR updates the logic used to populate `status.Disks` such that when a duplicate name is encountered, it is
deduplicated by appending and incremented suffix, e.g. `_1`, `_2`, etc.
@github-actions github-actions bot added the size/XXL Denotes a PR that changes 1000+ lines. label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL Denotes a PR that changes 1000+ lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants