Project

General

Profile

Actions

Bug #31847

open

nil-Exception when viewing VM (disk) details with fog-libvirt 0.8.0

Added by Florian Pritz over 3 years ago. Updated about 2 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Compute resources - libvirt
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

We have recently upgraded to foreman 2.3.2 and somehow we also got fog-libvirt 0.8.0 during that upgrade. Now, listing the VM details fails for some of our VMs with the following exception:

Backtrace for 'Failed to fetch vm information' error (ActionView::Template::Error): undefined method `allocation' for nil:NilClass
 | /usr/share/foreman/app/views/compute_resources_vms/show/_libvirt.html.erb:46:in `block in _app_views_compute_resources_vms_show__libvirt_html_erb___3550598388922153960_47210195739420'
 | /usr/share/foreman/app/views/compute_resources_vms/show/_libvirt.html.erb:43:in `each'
 | /usr/share/foreman/app/views/compute_resources_vms/show/_libvirt.html.erb:43:in `_app_views_compute_resources_vms_show__libvirt_html_erb___3550598388922153960_47210195739420'
 ...

We are running with ruby 2.5 on Ubuntu 18.04.

I've discovered that this bug happens, when a VM has a block disk in the XML as follows:

<disk type="block" ...>
  ...
  <source dev="/foo/...">
</disk>

If I modify the XML and replace the "block" type with a "file" type, it works. The XML would look like this:

<disk type="file" ...>
  ...
  <source file="/foo/...">
</disk>
`

I have also determined that the issue happens due to the following change in fog-libvirt: https://github.com/fog/fog-libvirt/commit/f9df2f8d5e3c7008b33e8e642e1c62677e95f36f#diff-202c61eaa5442b1562357d52fe8d9ccfc84d82ff3b24439e8ec3db10bacf7b38R73

More specifically, it happens because the no-match return value of get_volume() has been changed from "{}" to "nil". If I change this return value back to "{}" the exception disappears and the VM details are shown in the webinterface again. Though, even then, I can only see real data for the "type=file" disks and I get some default/incorrect data for the "type=block" disk. Alternatively, I can change the return value of list_volumes() from the same file to "[{}]" in which case I get default/incorrect data for all disks of the VM, but at least it works. If that return value is hardcoded to "[]" I get the same exception no matter what get_volume() returns. I expect that there is some additional processing between the linked file and the template that raises the exception, but I cannot find it.

Note that there are two workarounds for this issue: 1) switch the VM disk from "block" to "file" or 2) "fix" the return value of get_volume(). I'm not sure what a proper fix would look like.

If you need any further information to reproduce this issue or if you want me to test any fixes, please do not hesitate to ask.

Actions #1

Updated by Florian Pritz over 2 years ago

We are still experiencing this issue. Any news?

Actions #2

Updated by Florian Pritz about 2 years ago

  • Found in Releases 3.1.2 added

We continue to see this issue with Foreman 3.1.2. Can you provide any information on when this will be resolved or what else you need to resolve it? Is anything about this issue unclear and hindering progress?

Actions

Also available in: Atom PDF