PropertyCollector.collectMultiple: Encounter ERROR when fetching a list of VMs and at the same time some VMs are being destroyed
manchiu opened this issue · 1 comments
Hi all, I am using list_virtual_machines.rb in fog/fog-vsphere and at the same time some VMs are being destroyed in my vCenter Server by other staffs. Then I encountered the below ERROR:
RbVmomi::Fault: ManagedObjectNotFound: The object has already been deleted or has not been completely created
/usr/local/bundle/gems/rbvmomi-1.13.0/lib/rbvmomi/connection.rb:63:in `parse_response'
/usr/local/bundle/gems/rbvmomi-1.13.0/lib/rbvmomi/connection.rb:92:in `call'
/usr/local/bundle/gems/rbvmomi-1.13.0/lib/rbvmomi/basic_types.rb:213:in `_call'
/usr/local/bundle/gems/rbvmomi-1.13.0/lib/rbvmomi/basic_types.rb:76:in `block (2 levels) in init'
/usr/local/bundle/gems/rbvmomi-1.13.0/lib/rbvmomi/vim/PropertyCollector.rb:23:in `collectMultiple'
/usr/local/bundle/bundler/gems/fog-vsphere-0a9a52896c88/lib/fog/vsphere/compute.rb:171:in `convert_vm_view_to_attr_hash'
/usr/local/bundle/bundler/gems/fog-vsphere-0a9a52896c88/lib/fog/vsphere/requests/compute/list_virtual_machines.rb:51:in `list_all_virtual_machines'
/usr/local/bundle/bundler/gems/fog-vsphere-0a9a52896c88/lib/fog/vsphere/requests/compute/list_virtual_machines.rb:16:in `list_virtual_machines'
Moreover, I have added some fields like datastore, resourcePool, customValue, guestNetInfo and network in the hash(ATTR_TO_PROP) for your reference.
ATTR_TO_PROP = {
id: 'config.instanceUuid',
name: 'name',
uuid: 'config.uuid',
template: 'config.template',
parent: 'parent',
hostname: 'summary.guest.hostName',
operatingsystem: 'summary.guest.guestFullName',
ipaddress: 'guest.ipAddress',
power_state: 'runtime.powerState',
connection_state: 'runtime.connectionState',
hypervisor: 'runtime.host',
tools_state: 'guest.toolsStatus',
tools_version: 'guest.toolsVersionStatus',
memory_mb: 'config.hardware.memoryMB',
cpus: 'config.hardware.numCPU',
corespersocket: 'config.hardware.numCoresPerSocket',
overall_status: 'overallStatus',
guest_id: 'config.guestId',
hardware_version: 'config.version',
cpuHotAddEnabled: 'config.cpuHotAddEnabled',
memoryHotAddEnabled: 'config.memoryHotAddEnabled',
firmware: 'config.firmware',
annotation: 'config.annotation',
# Patched by me
datastore: 'datastore',
resourcePool: 'resourcePool',
customValue: 'customValue',
guestNetInfo: 'guest.net',
network: 'network'
}.freeze
I suggest it should by-pass the VMs which are being destroyed instead of raising this error. Otherwise, I cannot get the list of other VMs if someone keeps destroying or cleaning up the VMs in my vCenter Server. Thanks
I'm incredibly sorry for somehow missing this and not following up! 😞
For this issue, I'd say that it's not right for rbvmomi
to bypass the VMs being destroyed. rbvmomi
is meant to mimic the web service API as closely as possible and this is how the PropertyCollector
works. While rbvmomi
does at some points provide some extensions to make things a bit easier, this is using the PropertyCollector
directly (and I do realize that this is because there is no abstraction provided above this layer and that is why fog-vsphere
is using it directly).
That said, you should be able to use rescue
to bypass this issue as it comes up. fog-vsphere
could do this for you in list_virtual_machines
or you could choose to do this in your calling code. Either way would work.