Project

General

Profile

Actions

Bug #24125

closed

Creating host on libvirt with hammer fails with fails with "undefined method `name' for nil:NilClass"

Added by Ondřej Pražák over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Category:
Compute resources - libvirt
Target version:

Description

Description of problem:
`hammer host create ...` fails with "undefined method `name' for nil:NilClass", when libvirt is down.

Steps to Reproduce:
1. systemctl stop libvirtd

2.

hammer -u admin -p changeme host create --architecture-id="3" --compute-resource-id="2" --domain-id="3" --environment-id="5" --ip="148.172.224.43" --location-id="5" --mac="94:e3:d9:06:72:48" --medium-id="10" --name="jhutar$RANDOM" --operatingsystem-id="3" --organization-id="6" --partition-table-id="141" --puppet-proxy-id="1" --root-password="\xea\xae\x8f\xf0\x98\x87\x8a\xe9\xb5\xa8\xd0\x9e\xec\x8b\xa4\xe6\xa9\x88\xe0\xae\x88\xe1\x8b\xb8\xe5\x83\x95\xf0\x97\xbf\xa3\xe7\x87\x93\xf0\x96\xa6\x9e\xeb\xa9\x83\xe7\x88\x8a\xe6\x88\x8f\xe7\x9d\x8d\xea\x85\xa0\xef\xac\x85" 

Actual results:

2018-06-26T03:48:50 [I|app|] Started POST "/api/hosts" for 10.16.184.126 at 2018-06-26 03:48:50 -0400
2018-06-26T03:48:50 [I|app|b3582] Processing by Api::V2::HostsController#create as JSON
2018-06-26T03:48:50 [I|app|b3582]   Parameters: {"location_id"=>5, "organization_id"=>6, "host"=>{"name"=>"jhutar8331", "location_id"=>5, "organization_id"=>6, "environment_id"=>5, "ip"=>"148.172.224.43", "mac"=>"94:e3:d9:06:72:48", "architecture_id"=>3, "domain_id"=>3, "puppet_proxy_id"=>"1", "puppetclass_ids"=>[], "operatingsystem_id"=>3, "medium_id"=>10, "ptable_id"=>141, "compute_resource_id"=>2, "build"=>true, "enabled"=>true, "managed"=>true, "compute_attributes"=>{"volumes_attributes"=>{}}, "content_facet_attributes"=>{}, "subscription_facet_attributes"=>{}, "overwrite"=>true, "host_parameters_attributes"=>[], "interfaces_attributes"=>[], "root_pass"=>"[FILTERED]"}, "apiv"=>"v2"}
2018-06-26T03:48:50 [I|app|b3582] Current user: foreman_admin (administrator)
2018-06-26T03:48:50 [I|app|b3582] Authorized user admin(Admin User)
2018-06-26T03:48:50 [I|app|b3582] Current user: admin (administrator)
2018-06-26T03:48:50 [I|app|b3582] Adding Compute instance for jhutar8331.xl2ppkfyft
2018-06-26T03:48:51 [W|app|b3582] Failed to create a compute 9zZ6tf (Libvirt) instance jhutar8331.xl2ppkfyft: undefined method `name' for nil:NilClass

NoMethodError: undefined method `name' for nil:NilClass
/usr/share/foreman/app/models/compute_resources/foreman/model/libvirt.rb:152:in `create_vm'
/usr/share/foreman/app/models/concerns/orchestration/compute.rb:78:in `setCompute'
/usr/share/foreman/app/models/concerns/orchestration.rb:222:in `execute'
/usr/share/foreman/app/models/concerns/orchestration.rb:145:in `block in process'
/usr/share/foreman/app/models/concerns/orchestration.rb:137:in `each'
/usr/share/foreman/app/models/concerns/orchestration.rb:137:in `process'
/usr/share/foreman/app/models/concerns/orchestration.rb:44:in `around_save_orchestration'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:135:in `run_callbacks'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:827:in `_run_save_callbacks'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/callbacks.rb:336:in `create_or_update'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/persistence.rb:129:in `save'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/validations.rb:44:in `save'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/attribute_methods/dirty.rb:35:in `save'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/transactions.rb:308:in `block (2 levels) in save'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/transactions.rb:384:in `block in with_transaction_returning_status'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `block in transaction'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:194:in `block in within_new_transaction'
/opt/rh/rh-ruby24/root/usr/share/ruby/monitor.rb:214:in `mon_synchronize'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:191:in `within_new_transaction'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `transaction'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/transactions.rb:210:in `transaction'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/transactions.rb:381:in `with_transaction_returning_status'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/transactions.rb:308:in `block in save'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/transactions.rb:323:in `rollback_active_record_state!'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/transactions.rb:307:in `save'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/suppressor.rb:42:in `save'
/usr/share/foreman/app/models/concerns/foreman/sti.rb:26:in `save'

Expected results:
Should create host

Actions #1

Updated by Ondřej Pražák over 5 years ago

  • Subject changed from Createing host on libvirt with hammer fails with fails with "undefined method `name' for nil:NilClass" to Createing host on libvirt with hammer fails with fails with "undefined method `name' for nil:NilClass"
  • Assignee set to Ondřej Pražák
Actions #2

Updated by Ondřej Pražák over 5 years ago

  • Subject changed from Createing host on libvirt with hammer fails with fails with "undefined method `name' for nil:NilClass" to Creating host on libvirt with hammer fails with fails with "undefined method `name' for nil:NilClass"
Actions #3

Updated by The Foreman Bot over 5 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5762 added
Actions #4

Updated by Ondřej Pražák over 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #5

Updated by The Foreman Bot over 5 years ago

  • Pull request https://github.com/theforeman/foreman/pull/5817 added
Actions #6

Updated by Marek Hulán over 5 years ago

  • Fixed in Releases 1.18.0 added

CP PR open and planned for 1.18, so setting the release accordingly

Actions #7

Updated by The Foreman Bot over 5 years ago

  • Pull request https://github.com/theforeman/foreman/pull/5823 added
Actions #8

Updated by Tomer Brisker over 5 years ago

  • Target version set to 1.18.1
  • Fixed in Releases 1.18.1, 1.19.0 added
  • Fixed in Releases deleted (1.18.0)
Actions

Also available in: Atom PDF