Project

General

Profile

Actions

Bug #2292

closed

Libvirt ComputeResource #test_connection fails

Added by Alexander Pánek almost 12 years ago. Updated over 7 years ago.

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

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)
Actions

Also available in: Atom PDF