Cannot edit libvirt hosts

Problem:

Clicking edit on libvirt hosts produces: Oops, we’re sorry but something went wrong undefined method `persisted?’ for nil:NilClass

Expected outcome:

Should proceed to the edit screen

Foreman and Proxy versions:

Foreman version: 2.5.4
Plugins:

  • foreman-tasks 4.1.5
  • foreman_bootdisk 17.1.0
  • foreman_discovery 17.0.1
  • foreman_hooks 0.3.17
  • foreman_remote_execution 4.5.4

Ubuntu pkgs:
foreman 2.5.4-2
foreman-cli 2.5.4-2
foreman-debug 2.5.4-2
foreman-ec2 2.5.4-2
foreman-installer 2.4.1-1
foreman-libvirt 2.5.4-2
foreman-postgresql 2.5.4-2
foreman-proxy 2.5.4-1
foreman-vmware 2.5.4-2
ruby-foreman-bootdisk 17.1.0-1
ruby-foreman-deface 1.5.3-1
ruby-foreman-discovery 17.0.1-1
ruby-foreman-hooks 0.3.17-1
ruby-foreman-remote-execution 9999-plugin+scratchbuild+20210810144503
ruby-foreman-remote-execution-core 1.4.8-1
ruby-foreman-salt 13.2.4-1
ruby-foreman-tasks 4.1.5-1
ruby-foreman-tasks-core 0.3.6-1
ruby-hammer-cli-foreman 2.5.0-1

Rake:
2022-03-23T18:40:23 [I|app|2a804849] Processing by HostsController#edit as HTML
2022-03-23T18:40:23 [I|app|2a804849] Parameters: {“id”=>“hostname.fqdn”}
2022-03-23T18:40:23 [I|app|2a804849] Rendering hosts/edit.html.erb within layouts/application
2022-03-23T18:40:23 [I|app|2a804849] Rendered hosts/_progress.html.erb (Duration: 4.0ms | Allocations: 5797)
2022-03-23T18:40:23 [I|app|2a804849] Rendered hosts/puppet/_main_tab_fields.html.erb (Duration: 11.0ms | Allocations: 7756)
2022-03-23T18:40:23 [I|app|2a804849] Rendered config_groups/_config_group.html.erb (Duration: 34.1ms | Allocations: 14366)
2022-03-23T18:40:23 [I|app|2a804849] Rendered config_groups/_config_group.html.erb (Duration: 4.5ms | Allocations: 6113)
2022-03-23T18:40:23 [I|app|2a804849] Rendered config_groups/_config_groups_selection.html.erb (Duration: 53.8ms | Allocations: 29178)
2022-03-23T18:40:23 [I|app|2a804849] Rendered collection of puppetclasses/_selectedClasses.html.erb [1 times] (Duration: 7.5ms | Allocations: 7002)
2022-03-23T18:40:23 [I|app|2a804849] Rendered collection of puppetclasses/_classes_in_groups.html.erb [0 times] (Duration: 0.0ms | Allocations: 3)
2022-03-23T18:40:23 [I|app|2a804849] Rendered puppetclasses/_classes.html.erb (Duration: 211.3ms | Allocations: 160128)
2022-03-23T18:40:23 [I|app|2a804849] Rendered puppetclasses/_class_selection.html.erb (Duration: 360.9ms | Allocations: 225236)
2022-03-23T18:40:23 [I|app|2a804849] Rendered hosts/puppet/_puppet_classes_tab.html.erb (Duration: 366.1ms | Allocations: 231171)
2022-03-23T18:40:23 [I|app|2a804849] Rendered nic/_base_form.html.erb (Duration: 45.4ms | Allocations: 23596)
2022-03-23T18:40:23 [I|app|2a804849] Rendered nic/_virtual_form.html.erb (Duration: 4.6ms | Allocations: 6608)
2022-03-23T18:40:23 [I|app|2a804849] Rendered compute_resources_vms/form/libvirt/_network.html.erb (Duration: 104.1ms | Allocations: 7406)
2022-03-23T18:40:23 [I|app|2a804849] Rendered nic/_provider_specific_form.html.erb (Duration: 126.5ms | Allocations: 14107)
2022-03-23T18:40:23 [I|app|2a804849] Rendered nic/manageds/_managed.html.erb (Duration: 185.8ms | Allocations: 56484)
2022-03-23T18:40:23 [I|app|2a804849] Rendered nic/_base_form.html.erb (Duration: 57.6ms | Allocations: 25279)
2022-03-23T18:40:23 [I|app|2a804849] Rendered nic/_virtual_form.html.erb (Duration: 4.7ms | Allocations: 6603)
2022-03-23T18:40:24 [I|app|2a804849] Rendered compute_resources_vms/form/libvirt/_network.html.erb (Duration: 106.9ms | Allocations: 7380)
2022-03-23T18:40:24 [I|app|2a804849] Rendered nic/_provider_specific_form.html.erb (Duration: 126.7ms | Allocations: 14016)
2022-03-23T18:40:24 [I|app|2a804849] Rendered nic/manageds/_managed.html.erb (Duration: 200.0ms | Allocations: 58056)
2022-03-23T18:40:24 [I|app|2a804849] Rendered hosts/_interfaces.html.erb (Duration: 392.8ms | Allocations: 120870)
2022-03-23T18:40:24 [I|app|2a804849] Rendered compute_resources_vms/form/libvirt/_base.html.erb (Duration: 85.2ms | Allocations: 8023)
2022-03-23T18:40:24 [I|app|2a804849] Rendered compute_resources_vms/form/libvirt/_volume.html.erb (Duration: 31.8ms | Allocations: 12706)
2022-03-23T18:40:24 [I|app|2a804849] Rendered compute_resources_vms/form/_volumes.html.erb (Duration: 68.8ms | Allocations: 19714)
2022-03-23T18:40:24 [I|app|2a804849] Rendered hosts/_compute_detail.html.erb (Duration: 159.8ms | Allocations: 33614)
2022-03-23T18:40:24 [I|app|2a804849] Rendered hosts/_compute.html.erb (Duration: 184.9ms | Allocations: 40338)
2022-03-23T18:40:24 [I|app|2a804849] Rendered hosts/_unattended.html.erb (Duration: 190.0ms | Allocations: 46137)
2022-03-23T18:40:24 [I|app|2a804849] Rendered hosts/_form.html.erb (Duration: 1054.6ms | Allocations: 442156)
2022-03-23T18:40:24 [I|app|2a804849] Rendered hosts/edit.html.erb within layouts/application (Duration: 1064.5ms | Allocations: 448590)
2022-03-23T18:40:24 [W|app|2a804849] undefined method persisted?' for nil:NilClass 2022-03-23T18:40:24 [I|app|2a804849] Backtrace for 'undefined method persisted?’ for nil:NilClass’ error (ActionView::Template::Error): undefined method `persisted?’ for nil:NilClass
2022-03-23T18:40:24 [I|app|2a804849] Rendering common/500.html.erb within layouts/application
2022-03-23T18:40:24 [I|app|2a804849] Rendered common/500.html.erb within layouts/application (Duration: 5.4ms | Allocations: 6125)
2022-03-23T18:40:24 [I|app|2a804849] Rendered layouts/_application_content.html.erb (Duration: 5.3ms | Allocations: 5816)
2022-03-23T18:40:24 [I|app|2a804849] Rendering layouts/base.html.erb
2022-03-23T18:40:24 [I|app|2a804849] Rendered layouts/base.html.erb (Duration: 6.8ms | Allocations: 7179)
2022-03-23T18:40:24 [I|app|2a804849] Completed 500 Internal Server Error in 1158ms (Views: 23.7ms | ActiveRecord: 72.0ms | Allocations: 487190)

This is only for existing libvirt hosts, new ones can be created and edited. The ones with the issue report the error “Failure: undefined method `allocation’ for nil:NilClass” when trying to select the VM info tab. What would be the best way to fix?

Here is the rake:
2022-03-24T16:46:19 [I|app|f8c13773] Started GET “/compute_resources/2-vmhost1/vms/11932d41-b967-4c63-b1c2-cab81324d152” for 10.242.40.121 at 2022-03-24 16:46:19 +0000
2022-03-24T16:46:19 [I|app|f8c13773] Processing by ComputeResourcesVmsController#show as HTML
2022-03-24T16:46:19 [I|app|f8c13773] Parameters: {“compute_resource_id”=>“2-vmhost1”, “id”=>“11932d41-b967-4c63-b1c2-cab81324d152”}
2022-03-24T16:46:19 [I|app|f8c13773] Rendering compute_resources_vms/show.html.erb within layouts/application
2022-03-24T16:46:19 [I|app|f8c13773] Rendered compute_resources_vms/show/_libvirt.html.erb (Duration: 12.5ms | Allocations: 7368)
2022-03-24T16:46:19 [I|app|f8c13773] Rendered compute_resources_vms/show.html.erb within layouts/application (Duration: 20.6ms | Allocations: 13515)
2022-03-24T16:46:19 [W|app|f8c13773] undefined method allocation' for nil:NilClass 2022-03-24T16:46:19 [I|app|f8c13773] Backtrace for 'undefined method allocation’ for nil:NilClass’ error (ActionView::Template::Error): undefined method `allocation’ for nil:NilClass
2022-03-24T16:46:19 [I|app|f8c13773] Rendering common/500.html.erb within layouts/application
2022-03-24T16:46:19 [I|app|f8c13773] Rendered common/500.html.erb within layouts/application (Duration: 4.6ms | Allocations: 6130)
2022-03-24T16:46:19 [I|app|f8c13773] Rendered layouts/_application_content.html.erb (Duration: 3.9ms | Allocations: 5813)
2022-03-24T16:46:19 [I|app|f8c13773] Rendering layouts/base.html.erb
2022-03-24T16:46:19 [I|app|f8c13773] Rendered layouts/base.html.erb (Duration: 5.2ms | Allocations: 7177)
2022-03-24T16:46:19 [I|app|f8c13773] Completed 500 Internal Server Error in 72ms (Views: 18.3ms | ActiveRecord: 1.8ms | Allocations: 42146)

Foreman’s libvirt compute resource is VERY limited, it would not work for VMs created outside of Foreman. Libvirt is an extremely open API with very complicated interface (ton of XML) and possibilities are huge. Foreman can only handle basic storage and network domains (directory with images, NAT network).

If you enable debug there should be a stacktrace that should help us to identify the line, to me it looks like the volume is not loaded correctly, is nil thus vol.allocation raises exception. There is not much we can do other than improve the error message.

I’m hitting a similar issue trying to “manage” compute infrastructure and VMs created outside of Foreman. While I understand your point, here, in my use-case I would like to bring into Foreman management several libvirt-based compute resources that were previously deployed. If there are steps that need to be taken to make these resources “Foreman-ready”, it would be nice to have those - I’m not opposed to making changes to make it work, but I don’t necessarily want to go through and re-deploy everything through Foreman that is already running.

Here’s what I have from the /var/log/foreman/production.log file - not sure if this helps anymore than what @twh already posted??

2022-03-25T12:53:44 [I|app|d3f437a7]   Rendered compute_resources_vms/show.html.erb within layouts/application (Duration: 1406.0ms | Al
locations: 4126)
2022-03-25T12:53:44 [W|app|d3f437a7] undefined method `allocation' for nil:NilClass
2022-03-25T12:53:44 [I|app|d3f437a7] Backtrace for 'undefined method `allocation' for nil:NilClass' error (ActionView::Template::Error): undefined method `allocation' for nil:NilClass
 d3f437a7 | /usr/share/foreman/app/views/compute_resources_vms/show/_libvirt.html.erb:46:in `block in _24e16322dd1c814b56e297c5095da50b'
 d3f437a7 | /usr/share/foreman/app/views/compute_resources_vms/show/_libvirt.html.erb:43:in `each'
 d3f437a7 | /usr/share/foreman/app/views/compute_resources_vms/show/_libvirt.html.erb:43:in `_24e16322dd1c814b56e297c5095da50b'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/base.rb:274:in `_run'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:185:in `block in render'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:182:in `instrument'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:385:in `instrument_render_template'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:183:in `render'
 d3f437a7 | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/partial_renderer.rb:357:in `block in render_partial'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `block in instrument'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `instrument'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/abstract_renderer.rb:87:in `instrument'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/partial_renderer.rb:346:in `render_partial'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/partial_renderer.rb:317:in `render'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/renderer.rb:65:in `render_partial_to_object'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/renderer.rb:53:in `render_partial'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/helpers/rendering_helper.rb:38:in `render'
 d3f437a7 | /usr/share/foreman/app/views/compute_resources_vms/show.html.erb:25:in `_b6c24aef3a3d464b0bd0da3171b64f9b'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/base.rb:274:in `_run'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:185:in `block in render'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:182:in `instrument'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:385:in `instrument_render_template'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/template.rb:183:in `render'
 d3f437a7 | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/template_renderer.rb:58:in `block (2 levels) in render_template'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `block in instrument'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `instrument'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/abstract_renderer.rb:87:in `instrument'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/template_renderer.rb:57:in `block in render_template'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/template_renderer.rb:65:in `render_with_layout'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/template_renderer.rb:56:in `render_template'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/template_renderer.rb:13:in `render'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/renderer/renderer.rb:29:in `render_to_object'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/rendering.rb:117:in `block in _render_template'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/base.rb:304:in `in_rendering_context'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/rendering.rb:116:in `_render_template'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/streaming.rb:218:in `_render_template'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/rendering.rb:103:in `render_to_body'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/rendering.rb:52:in `render_to_body'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/renderers.rb:142:in `render_to_body'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/abstract_controller/rendering.rb:25:in `render'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/rendering.rb:36:in `render'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
 d3f437a7 | /usr/share/ruby/benchmark.rb:308:in `realtime'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/core_ext/benchmark.rb:14:in `ms'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/instrumentation.rb:44:in `block in render'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
 d3f437a7 | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/instrumentation.rb:43:in `render'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/implicit_render.rb:35:in `default_render'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/abstract_controller/base.rb:195:in `process_action'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:112:in `block in run_callbacks'
 d3f437a7 | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d3f437a7 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d3f437a7 | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d3f437a7 | /usr/share/gems/gems/audited-4.9.0/lib/audited/sweeper.rb:14:in `around'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d3f437a7 | /usr/share/gems/gems/audited-4.9.0/lib/audited/sweeper.rb:14:in `around'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:139:in `run_callbacks'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/abstract_controller/callbacks.rb:41:in `process_action'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/rescue.rb:22:in `process_action'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `block in instrument'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/notifications.rb:180:in `instrument'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
 d3f437a7 | /usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/abstract_controller/base.rb:136:in `process'
 d3f437a7 | /usr/share/gems/gems/actionview-6.0.4.7/lib/action_view/rendering.rb:39:in `process'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal.rb:190:in `dispatch'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal.rb:254:in `dispatch'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/journey/router.rb:49:in `block in serve'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/journey/router.rb:32:in `each'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/journey/router.rb:32:in `serve'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/routing/route_set.rb:834:in `call'
 d3f437a7 | /usr/share/gems/gems/apipie-dsl-2.4.0/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 d3f437a7 | /usr/share/gems/gems/apipie-rails-0.5.17/lib/apipie/static_dispatcher.rb:66:in `call'
 d3f437a7 | /usr/share/gems/gems/apipie-rails-0.5.17/lib/apipie/extractor/recorder.rb:137:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
 d3f437a7 | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 d3f437a7 | /usr/share/gems/gems/apipie-rails-0.5.17/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb:15:in `call'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/etag.rb:27:in `call'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/conditional_get.rb:27:in `call'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
 d3f437a7 | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:266:in `context'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/cookies.rb:654:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/callbacks.rb:101:in `run_callbacks'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 d3f437a7 | /usr/share/gems/gems/railties-6.0.4.7/lib/rails/rack/logger.rb:37:in `call_app'
 d3f437a7 | /usr/share/gems/gems/railties-6.0.4.7/lib/rails/rack/logger.rb:28:in `call'
 d3f437a7 | /usr/share/gems/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 d3f437a7 | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/request_id.rb:27:in `call'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'
 d3f437a7 | /usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/executor.rb:14:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/static.rb:126:in `call'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/ssl.rb:74:in `call'
 d3f437a7 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_dispatch/middleware/host_authorization.rb:97:in `call'
 d3f437a7 | /usr/share/gems/gems/secure_headers-6.3.0/lib/secure_headers/middleware.rb:11:in `call'
 d3f437a7 | /usr/share/gems/gems/railties-6.0.4.7/lib/rails/engine.rb:527:in `call'
 d3f437a7 | /usr/share/gems/gems/railties-6.0.4.7/lib/rails/railtie.rb:190:in `public_send'
 d3f437a7 | /usr/share/gems/gems/railties-6.0.4.7/lib/rails/railtie.rb:190:in `method_missing'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:74:in `block in call'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `each'
 d3f437a7 | /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `call'
 d3f437a7 | /usr/share/gems/gems/puma-5.6.2/lib/puma/configuration.rb:252:in `call'
 d3f437a7 | /usr/share/gems/gems/puma-5.6.2/lib/puma/request.rb:77:in `block in handle_request'
 d3f437a7 | /usr/share/gems/gems/puma-5.6.2/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
 d3f437a7 | /usr/share/gems/gems/puma-5.6.2/lib/puma/request.rb:76:in `handle_request'
 d3f437a7 | /usr/share/gems/gems/puma-5.6.2/lib/puma/server.rb:441:in `process_client'
 d3f437a7 | /usr/share/gems/gems/puma-5.6.2/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
 d3f437a7 | /usr/share/gems/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2022-03-25T12:53:44 [I|app|d3f437a7]   Rendering common/500.html.erb within layouts/application
2022-03-25T12:53:44 [I|app|d3f437a7]   Rendered common/500.html.erb within layouts/application (Duration: 11.9ms | Allocations: 6941)
2022-03-25T12:53:44 [I|app|d3f437a7]   Rendered layouts/_application_content.html.erb (Duration: 5.2ms | Allocations: 5998)
2022-03-25T12:53:44 [I|app|d3f437a7]   Rendering layouts/base.html.erb
2022-03-25T12:53:44 [I|app|d3f437a7]   Rendered layouts/base.html.erb (Duration: 9.7ms | Allocations: 10100)
2022-03-25T12:53:44 [I|app|d3f437a7] Completed 500 Internal Server Error in 9872ms (Views: 33.9ms | ActiveRecord: 2.3ms | Allocations: 38921)

This only confirms what I thought, volume is nil, that domain is not compatible with Foreman.

When you say “volume is nil”, what does that mean? Or, perhaps more precisely, what item is missing from the domain’s XML configuration that Foreman is expecting to find? How do I go about making the domain “compatible”?

Create a VM through Foreman, then compare the libvirt’s domain XML (virsh edit VM) with the one which fails. It needs to be exactly the same (except the data like VM name, memory size, UUID etc). That is what Foreman “understands”, anything else will typically cause Foreman to raise an exception.

We hit this, and doing some very quick investigation, at least for us on storage, it is an issue in fog (https://github.com/fog/fog-libvirt/pull/117) and also mentioned in #34479 (Bug #34479: fog-libvirt change not being handled in the template - Foreman). I haven’t tested the fix but it aligns as we have some volumes using dev.

1 Like