Network interruption causes WaitForUpdatesEx blocking issue
Open
Nobody has claimed this yet.
bug
high priority
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 763
- PR merge metrics
- No merged PRs in 30d
Description
The following code retrieves a list of host objects every 10 seconds. For my test, I run this code on my laptop inside of a VMware Workstation Ubuntu VM. This allows me to use VMware Workstation to simulate a break in network connectivity (adapter is up, but client is unable to communicate with vSphere).
- Allow the code to run for a few cycles (2-3 is enough).
- Uncheck 'VM/Settings/Network Adapter' to simulate a break in network connectivity.
- Wait 30 seconds - observe that 'Waiting for updates' does not show any updates or errors
- Re-enable 'VM/Settings/Network Adapter' to restore network connectivity
- Observe that 'Waiting for updates' does not show any further updates or errors.
from pyVim.connect import SmartConnect
import pyVmomi
def test_loop(username, password, host, port):
# Connect and collect instance info
service_instance = SmartConnect(user=username, pwd=password, host=host, port=port)
content = service_instance.RetrieveContent()
# Create a container view
container_view = content.viewManager.CreateContainerView(
container=content.rootFolder,
type=[pyVmomi.vim.HostSystem],
recursive=True)
# Create a traversal spec
traversal_spec = pyVmomi.vim.PropertyCollector.TraversalSpec(
name='traversal_spec',
path='view',
skip=False,
type=pyVmomi.vim.view.ContainerView)
# Create an object spec
object_spec = pyVmomi.vim.PropertyCollector.ObjectSpec(
obj=container_view,
selectSet=[traversal_spec],
skip=False)
# Create a property specs for host events
property_spec_host_events = pyVmomi.vim.PropertyCollector.PropertySpec(
all=False,
pathSet=["runtime.bootTime"],
type=pyVmomi.vim.HostSystem)
# Create a property filter spec
property_filter_spec = pyVmomi.vim.PropertyCollector.FilterSpec(
objectSet=[object_spec],
propSet=[property_spec_host_events],
reportMissingObjectsInResults=True)
# Create the property filter
content.propertyCollector.CreateFilter(
spec=property_filter_spec,
partialUpdates=True)
# Set up the wait options
max_wait = 10
wait_options = pyVmomi.vim.PropertyCollector.WaitOptions(
maxWaitSeconds=max_wait,
maxObjectUpdates=None)
# Initialize update version and start time
update_version = None
# Loop until exit flag has been set
while True:
print("Waiting for updates from (v {})...({} seconds)".format(
update_version,
wait_options.maxWaitSeconds))
# Block until an update is received or timeout is received
update_set = content.propertyCollector.WaitForUpdatesEx(
version=update_version,
options=wait_options)
if update_set is None:
print("Timeout/Requery")
# Reset the update version number to force a full requery.
update_version = None
else:
print(" Received Update (v{})".format(update_set.version))
update_version = update_set.version
print("")
# Run the test.
test_loop('root', 'password', 'localhost', 443)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.