vmware / govmomi

Go library for the VMware vSphere API
Apache License 2.0
2.3k stars 910 forks source link

[BUG] WaitEx omits updates when the server GUID is not set #3417

Closed spacegospod closed 5 months ago

spacegospod commented 5 months ago

Describe the bug

It is possible for Managed Object References to be returned with an empty string for the ServerGUID field. I am not sure whether this is a problem with the SOAP response serialization or if its just they way some of the VC APIs work.

In any case the new WaitEx method filters incoming updates by matching the entire Managed Object Reference. This means that if the ServerGUID field is an empty string the entire update is filtered out.

This is the exact line where the the filtering occurs https://github.com/vmware/govmomi/blob/main/task/wait.go#L144

WaitEx was introduced in https://github.com/vmware/govmomi/pull/3331 The original Wait method did not have the MOR comparison

To Reproduce Steps to reproduce the behavior:

The bug is easily reproducibly by using govc

  1. Create a virtual disk on a datastore
  2. Execute datastore.disk.info
  3. Observe that the execution hangs up

Reverting https://github.com/vmware/govmomi/pull/3331 or modifying the MOR comparison to just check the Value field resolves the problem.

Expected behavior

WaitEx should not drop valid updates and should not cause the execution to hang for the duration of the default timeout

Affected version

Latest code from the main branch

Screenshots/Debug Output N/A

Additional context

This issue is the root cause for https://github.com/hashicorp/terraform-provider-vsphere/issues/2162

spacegospod commented 5 months ago

@akutz I'd appreciate your advice on how to fix this. https://github.com/vmware/govmomi/pull/3331 is quite complex