Skip to content

Commit

Permalink
Rescue VM volume attachments NotFound
Browse files Browse the repository at this point in the history
When a VM is in `ERROR` state (and possibly other states) the
vm.volume_attachments call may fail raising an
Fog::OpenStack::Compute::NotFound exception and causing the entire
inventory refresh to fail. This rescue allows the inventory refresh to
pass (and in the case of a VM in ERROR state, the VM will show up in
ManageIQ inventory as 'non_operational').
  • Loading branch information
jaywcarman committed Jun 18, 2024
1 parent fa61c2d commit 45972ed
Showing 1 changed file with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -411,21 +411,25 @@ def parse_vm(vm, hosts)
# Don't worry about filling in the volume, since the volume service refresh
# will take care of that.
if !vm.attributes.fetch("os-extended-volumes:volumes_attached", []).empty?
vm.volume_attachments.each do |attachment|
# Skip Volume mounts without mount point
next if attachment['device'].blank?

dev = File.basename(attachment['device'])
persister.disks.find_or_build_by(
:hardware => hardware,
# reuse the device names from above in the event that this is an
# instance that was booted from a volume
:device_name => attachment_names.fetch(dev, dev)
).assign_attributes(
:location => dev,
:device_type => "disk",
:controller_type => "openstack"
)
begin
vm.volume_attachments.each do |attachment|
# Skip Volume mounts without mount point
next if attachment['device'].blank?

dev = File.basename(attachment['device'])
persister.disks.find_or_build_by(
:hardware => hardware,
# reuse the device names from above in the event that this is an
# instance that was booted from a volume
:device_name => attachment_names.fetch(dev, dev)
).assign_attributes(
:location => dev,
:device_type => "disk",
:controller_type => "openstack"
)
end
rescue Fog::OpenStack::Compute::NotFound => err
_log.warn("Unable to retrieve VM volume attachments name=#{vm.name} id=#{vm.id} state=#{vm.state} err=#{err}")
end
end
vm_and_template_labels(server, vm.metadata || [])
Expand Down

0 comments on commit 45972ed

Please sign in to comment.