Bug #2292
closedLibvirt ComputeResource #test_connection fails
Description
Since clicking "Test connection" while editing a Compute resource causes Foreman to display the error "Unable to save; undefined method `text' for nil:NilClass", I have tried to find out where this error actually comes from.
In the controller app/controllers/compute_resources_controller#test_connection are basically two calls: one to initialize ComputeResource (in this case Libvirt) and one to actually test the connection. The former works, the latter causes the above error.
At some point in Foreman::Model::Libvirt#test_connection it somehow tries to access #hypervisor, which returns client.nodes.first, but client is a Libvirt::Connect and does not have a method #nodes.
I tried to replay the whole thing in the console:
irb(main):003:0> a = ::Fog::Compute.new :provider => 'Libvirt', :libvirt_uri => 'qemu+tcp://monster.HOSTNAME/system' => #<Fog::Compute::Libvirt::Real:70085136428260 @ip_command=nil @client=#<Libvirt::Connect:0x7f7bef454fa8> @uri=#<Fog::Compute::LibvirtUtil::URI:0x7f7bef457a50 @parsed_uri=#<URI::Generic:0x7f7bef454d78 URL:qemu+tcp://monster.HOSTNAME/system>, @uri="qemu+tcp://monster.HOSTNAME/system">> irb(main):004:0> a.client => #<Libvirt::Connect:0x7f7bef454fa8> irb(main):005:0> a.client.nodes NoMethodError: undefined method `nodes' for #<Libvirt::Connect:0x7f7bef454fa8> from (irb):5 from :0
Since I am not sure what exactly is supposed to happen at that point, I'll just paste the stacktrace that I managed to gather here. Originally there was no stacktrace, so I added a seperate call to #client.nodes with a begin/rescue block around it, capturing the exception and printing the backtrace line by line.
Started PUT "/compute_resources/test_connection" for 10.8.5.38 at Thu Mar 07 14:46:26 +0100 2013 Processing by ComputeResourcesController#test_connection as Parameters: {"authenticity_token"=>"i5ZXs9gy8xoCJmdFZCDdWmjNobP5NNc1Anrs9M9LN2c=", "compute_resource"=>{"url"=>"qemu+tcp://monster.HOSTNAME/system", "description"=>"MONSTER MONSTER PARTY", "provider"=>"Libvirt", "name"=>"monster.HOSTNAME"}, "utf8"=>"✓"} User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 7 LIMIT 1 Setting current user thread-local variable to igor.galic Setting Load (0.4ms) SELECT "settings".* FROM "settings" WHERE "settings"."name" = 'authorize_login_delegation' ORDER BY LOWER(settings.name) LIMIT 1 CACHE (0.0ms) SELECT "settings".* FROM "settings" WHERE "settings"."name" = 'authorize_login_delegation' ORDER BY LOWER(settings.name) LIMIT 1 SQL (0.3ms) SELECT 1 FROM "compute_resources" WHERE ("compute_resources"."name" = 'monster.HOSTNAME') LIMIT 1 /usr/local/share/foreman/vendor/ruby/1.8/bundler/gems/fog-6d651d777d80/lib/fog/libvirt/models/compute/util/util.rb:12:in `xml_element' /usr/local/share/foreman/vendor/ruby/1.8/bundler/gems/fog-6d651d777d80/lib/fog/libvirt/requests/compute/get_node_info.rb:27:in `node_attr' /usr/local/share/foreman/vendor/ruby/1.8/bundler/gems/fog-6d651d777d80/lib/fog/libvirt/requests/compute/get_node_info.rb:17:in `get_node_info' /usr/local/share/foreman/vendor/ruby/1.8/bundler/gems/fog-6d651d777d80/lib/fog/libvirt/requests/compute/get_node_info.rb:16:in `each' /usr/local/share/foreman/vendor/ruby/1.8/bundler/gems/fog-6d651d777d80/lib/fog/libvirt/requests/compute/get_node_info.rb:16:in `get_node_info' /usr/local/share/foreman/vendor/ruby/1.8/bundler/gems/fog-6d651d777d80/lib/fog/libvirt/models/compute/nodes.rb:13:in `all' /usr/local/share/foreman/vendor/ruby/1.8/bundler/gems/fog-6d651d777d80/lib/fog/core/collection.rb:141:in `lazy_load' /usr/local/share/foreman/vendor/ruby/1.8/bundler/gems/fog-6d651d777d80/lib/fog/core/collection.rb:15:in `to_s' /usr/local/share/foreman/vendor/ruby/1.8/gems/activesupport-3.0.20/lib/active_support/buffered_logger.rb:60:in `add' /usr/local/share/foreman/vendor/ruby/1.8/gems/activesupport-3.0.20/lib/active_support/buffered_logger.rb:76:in `debug' /usr/local/share/foreman/lib/foreman/model/libvirt.rb:119:in `client' /usr/local/share/foreman/lib/foreman/model/libvirt.rb:109:in `hypervisor' /usr/local/share/foreman/lib/foreman/model/libvirt.rb:45:in `test_connection' /usr/local/share/foreman/app/controllers/compute_resources_controller.rb:77:in `test_connection' [...] /usr/share/phusion-passenger/helper-scripts/passenger-spawn-server:99 Rendered compute_resources/form/_libvirt.html.erb (23.6ms) Rendered compute_resources/_form.html.erb (28.1ms) Completed 200 OK in 67ms (Views: 28.8ms | ActiveRecord: 3.1ms)
Updated by Dominic Cleal almost 12 years ago
- Status changed from New to Feedback
So on IRC yesterday, I think we tracked this down to the <system>
tag missing from libvirt's sysinfo (see `virsh sysinfo`), which Fog expected to always be there. Did you find out anything from libvirt upstream about whether it's optional or a bug? If it's optional, we should fix this in Fog.
Updated by Igor Galić almost 12 years ago
Dominic, thanks for the reminder. I didn't follup up with upstream yesterday, doing that now.
Updated by Igor Galić almost 12 years ago
Just as a reminder, this is what `virsh sysinfo` returns:
<sysinfo type='smbios'> <bios> <entry name='vendor'>Intel Corporation</entry> <entry name='version'>S5000.86B.10.00.0088.031420081550</entry> <entry name='date'>03/14/2008</entry> <entry name='release'>10.0</entry> </bios> <processor> <entry name='socket_destination'>CPU1</entry> <entry name='type'>Central Processor</entry> <entry name='family'>Xeon</entry> <entry name='manufacturer'>Intel(R) Corporation</entry> <entry name='signature'>Type 0, Family 6, Model 15, Stepping 11</entry> <entry name='version'>Intel(R) Xeon(R) CPU E5335 @ 2.00GHz</entry> <entry name='external_clock'>1333 MHz</entry> <entry name='max_speed'>2000 MHz</entry> <entry name='status'>Populated, Enabled</entry> <entry name='serial_number'>Not Specified</entry> <entry name='part_number'>Not Specified</entry> </processor> <processor> <entry name='socket_destination'>CPU2</entry> <entry name='type'>Central Processor</entry> <entry name='family'>Xeon</entry> <entry name='manufacturer'>Intel(R) Corporation</entry> <entry name='signature'>Type 0, Family 6, Model 15, Stepping 11</entry> <entry name='version'>Intel(R) Xeon(R) CPU E5335 @ 2.00GHz</entry> <entry name='external_clock'>1333 MHz</entry> <entry name='max_speed'>2000 MHz</entry> <entry name='status'>Populated, Enabled</entry> <entry name='serial_number'>Not Specified</entry> <entry name='part_number'>Not Specified</entry> </processor> <memory_device> <entry name='size'>2048 MB</entry> <entry name='form_factor'>FB-DIMM</entry> <entry name='locator'>ONBOARD DIMM_A1</entry> <entry name='bank_locator'>Channel A</entry> <entry name='type'>DDR2 FB-DIMM</entry> <entry name='type_detail'>Synchronous</entry> <entry name='speed'>667 MHz</entry> <entry name='manufacturer'>80CE</entry> <entry name='serial_number'>2920456C</entry> <entry name='part_number'>M395T5750EZ4-CE66</entry> </memory_device> <memory_device> <entry name='size'>2048 MB</entry> <entry name='form_factor'>FB-DIMM</entry> <entry name='locator'>ONBOARD DIMM_A2</entry> <entry name='bank_locator'>Channel A</entry> <entry name='type'>DDR2 FB-DIMM</entry> <entry name='type_detail'>Synchronous</entry> <entry name='speed'>667 MHz</entry> <entry name='manufacturer'>80CE</entry> <entry name='serial_number'>29284D22</entry> <entry name='part_number'>M395T5750EZ4-CE66</entry> </memory_device> <memory_device> <entry name='size'>2048 MB</entry> <entry name='form_factor'>FB-DIMM</entry> <entry name='locator'>ONBOARD DIMM_B1</entry> <entry name='bank_locator'>Channel B</entry> <entry name='type'>DDR2 FB-DIMM</entry> <entry name='type_detail'>Synchronous</entry> <entry name='speed'>667 MHz</entry> <entry name='manufacturer'>80CE</entry> <entry name='serial_number'>29284D38</entry> <entry name='part_number'>M395T5750EZ4-CE66</entry> </memory_device> <memory_device> <entry name='size'>2048 MB</entry> <entry name='form_factor'>FB-DIMM</entry> <entry name='locator'>ONBOARD DIMM_B2</entry> <entry name='bank_locator'>Channel B</entry> <entry name='type'>DDR2 FB-DIMM</entry> <entry name='type_detail'>Synchronous</entry> <entry name='speed'>667 MHz</entry> <entry name='manufacturer'>80CE</entry> <entry name='serial_number'>291E6D0A</entry> <entry name='part_number'>M395T5750EZ4-CE66</entry> </memory_device> <memory_device> <entry name='size'>2048 MB</entry> <entry name='form_factor'>FB-DIMM</entry> <entry name='locator'>ONBOARD DIMM_C1</entry> <entry name='bank_locator'>Channel C</entry> <entry name='type'>DDR2 FB-DIMM</entry> <entry name='type_detail'>Synchronous</entry> <entry name='speed'>667 MHz</entry> <entry name='manufacturer'>80CE</entry> <entry name='serial_number'>29284E26</entry> <entry name='part_number'>M395T5750EZ4-CE66</entry> </memory_device> <memory_device> <entry name='size'>2048 MB</entry> <entry name='form_factor'>FB-DIMM</entry> <entry name='locator'>ONBOARD DIMM_C2</entry> <entry name='bank_locator'>Channel C</entry> <entry name='type'>DDR2 FB-DIMM</entry> <entry name='type_detail'>Synchronous</entry> <entry name='speed'>667 MHz</entry> <entry name='manufacturer'>80CE</entry> <entry name='serial_number'>29284DF0</entry> <entry name='part_number'>M395T5750EZ4-CE66</entry> </memory_device> <memory_device> <entry name='size'>2048 MB</entry> <entry name='form_factor'>FB-DIMM</entry> <entry name='locator'>ONBOARD DIMM_D1</entry> <entry name='bank_locator'>Channel D</entry> <entry name='type'>DDR2 FB-DIMM</entry> <entry name='type_detail'>Synchronous</entry> <entry name='speed'>667 MHz</entry> <entry name='manufacturer'>80CE</entry> <entry name='serial_number'>29284DF2</entry> <entry name='part_number'>M395T5750EZ4-CE66</entry> </memory_device> <memory_device> <entry name='size'>2048 MB</entry> <entry name='form_factor'>FB-DIMM</entry> <entry name='locator'>ONBOARD DIMM_D2</entry> <entry name='bank_locator'>Channel D</entry> <entry name='type'>DDR2 FB-DIMM</entry> <entry name='type_detail'>Synchronous</entry> <entry name='speed'>667 MHz</entry> <entry name='manufacturer'>80CE</entry> <entry name='serial_number'>29284D97</entry> <entry name='part_number'>M395T5750EZ4-CE66</entry> </memory_device> </sysinfo>
The <system></system> block with uuid, manufacturer, product and serial we usually see is missing here. The question is whether this is expected behaviour.
Updated by Igor Galić almost 12 years ago
"Linking" Fog bug: https://github.com/fog/fog/issues/1652
Updated by Benjamin Papillon almost 11 years ago
Hello,
Fog bug is closed. Do you still have the issue with Foreman? Can we close this bug?
Regards
Updated by Dominic Cleal about 10 years ago
- Category changed from Compute resources to Compute resources - libvirt
Updated by Anonymous over 7 years ago
- Status changed from Feedback to Resolved
no reaction, closing.