Project

General

Profile

Actions

Bug #10111

closed

"primary_interface is nil" error when editing unmanaged host

Added by Dominic Cleal almost 9 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Category:
Host creation
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

On Foreman 1.8.0-RC2, we have the following unmanaged host saved in Foreman (which has unattended: true, the default):

#<Host::Managed id: 5, name: "builder01.ci.theforeman.org", last_compile: "2015-04-10 10:48:05", last_freshcheck: nil, last_report: "2015-04-10 10:48:02" 
, updated_at: "2015-04-10 10:48:29", source_file_id: nil, created_at: "2013-08-12 15:04:20", root_pass: nil, serial: nil, puppet_status: 0, architecture_id: 1, operatingsystem_id: 1, environment_id: 1, ptable_id: nil, medium_id: nil, build: false, comment: "", disk: nil,
installed_at: nil, model_id: 1, hostgroup_id: 7, owner_id: 1, owner_type: "usergroup", enabled: true, puppet_ca_proxy_id: nil, managed: false, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: nil, puppet_proxy_id: nil, certname: "builder01.ci.theforeman.or
g", image_id: nil, organization_id: nil, location_id: nil, type: "Host::Managed", compute_profile_id: nil, otp: nil, realm_id: nil, provision_method: "build", grub_pass: "">

When editing it through the UI or the API with Hammer, it throws one of the the following errors:

Started PUT "/api/hosts/5" for ::1 at 2015-04-10 11:08:10 +0000
2015-04-10 11:08:10 [I] Processing by Api::V2::HostsController#update as JSON
2015-04-10 11:08:10 [I] Parameters: {"host"=>{"owner_id"=>"1", "puppetclass_ids"=>nil, "host_parameters_attributes"=>{}, "puppet_ca_proxy_id"=>nil, "compute_attributes"=>{"volumes_attributes"=>{}}, "interfaces_attributes"=>{}, "puppet_proxy_id"=>nil, "owner_type"=>"user
group"}, "apiv"=>"v2", "id"=>"5"}
2015-04-10 11:08:10 [I] Authorized user dcleal(Dominic Cleal)
2015-04-10 11:08:10 [E] Host::Base#domain_id= delegated to primary_interface.domain_id=, but primary_interface is nil: #<Host::Managed id: 5, name: "builder01.ci.theforeman.org", last_compile: "2015-04-10 10:48:05", last_freshcheck: nil, last_report: "2015-04-10 10:48:02"
, updated_at: "2015-04-10 10:48:29", source_file_id: nil, created_at: "2013-08-12 15:04:20", root_pass: nil, serial: nil, puppet_status: 0, architecture_id: 1, operatingsystem_id: 1, environment_id: 1, ptable_id: nil, medium_id: nil, build: false, comment: "", disk: nil,
installed_at: nil, model_id: 1, hostgroup_id: 7, owner_id: 1, owner_type: "usergroup", enabled: true, puppet_ca_proxy_id: nil, managed: false, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: nil, puppet_proxy_id: nil, certname: "builder01.ci.theforeman.or
g", image_id: nil, organization_id: nil, location_id: nil, type: "Host::Managed", compute_profile_id: nil, otp: nil, realm_id: nil, provision_method: "build", grub_pass: ""> (RuntimeError)
/usr/share/foreman/app/models/host/base.rb:74:in `rescue in domain_id='
/usr/share/foreman/app/models/host/base.rb:71:in `domain_id='
/usr/share/foreman/app/models/host/managed.rb:825:in `block in assign_hostgroup_attributes'
/usr/share/foreman/app/models/host/managed.rb:822:in `each'
/usr/share/foreman/app/models/host/managed.rb:822:in `assign_hostgroup_attributes'
/usr/share/foreman/app/models/host/managed.rb:544:in `set_hostgroup_defaults'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:429:in `_run__2635687082887834559__validation__744022455904087883__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_validation_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activemodel-3.2.8/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
/opt/rh/ruby193/root/usr/share/gems/gems/activemodel-3.2.8/lib/active_model/validations.rb:194:in `valid?'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/validations.rb:69:in `valid?'
/usr/share/foreman/app/models/concerns/orchestration.rb:48:in `valid?'

Or through the UI:

Started PUT "/hosts/builder01.ci.theforeman.org" for ::1 at 2015-04-10 11:11:58 +0000
2015-04-10 11:11:58 [I] Processing by HostsController#update as */*
2015-04-10 11:11:58 [I] Parameters: {"utf8"=>"✓", "authenticity_token"=>"eoT6xnw5OXh/QC34aJf3SWQTJKb55R/MW9NO1ExS99o=", "host"=>{"name"=>"builder01.ci.theforeman.org", "hostgroup_id"=>"7", "environment_id"=>"1", "puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "puppetclass_ids"=>[""], "managed"=>"f", "progress_report_id"=>"[FILTERED]", "is_owned_by"=>"1-Usergroups", "enabled"=>"1", "model_id"=>"1", "comment"=>"", "overwrite"=>"false"}, "id"=>"builder01.ci.theforeman.org"}
2015-04-10 11:11:58 [W] Operation FAILED: Host::Base#name= delegated to primary_interface.name=, but primary_interface is nil: #<Host::Managed id: 5, name: "builder01.ci.theforeman.org", last_compile: "2015-04-10 10:48:05", last_freshcheck: nil, last_report: "2015-04-10 10:48:02", updated_at: "2015-04-10 10:48:29", source_file_id: nil, created_at: "2013-08-12 15:04:20", root_pass: nil, serial: nil, puppet_status: 0, architecture_id: 1, operatingsystem_id: 1, environment_id: 1, ptable_id: nil, medium_id: nil, build: false, comment: "", disk: nil, installed_at: nil, model_id: 1, hostgroup_id: 7, owner_id: 1, owner_type: "User", enabled: true, puppet_ca_proxy_id: 1, managed: false, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: nil, puppet_proxy_id: 1, certname: "builder01.ci.theforeman.org", image_id: nil, organization_id: nil, location_id: nil, type: "Host::Managed", compute_profile_id: nil, otp: nil, realm_id: nil, provision_method: "build", grub_pass: "">
2015-04-10 11:11:58 [I] Rendered common/500.html.erb (4.3ms)
2015-04-10 11:11:58 [I] Completed 500 Internal Server Error in 17ms (Views: 7.1ms | ActiveRecord: 1.1ms)

Since this is an unmanaged host, I wouldn't expect it to have a primary interface set. (The MoveHostNicsToInterfaces migration skips unmanaged hosts, so NIC classes aren't ever created for unmanaged hosts.)


Related issues 1 (0 open1 closed)

Related to Foreman - Bug #9498: Unmanaged host name cannot be changed after NICs migrationDuplicate02/22/2015Actions
Actions #1

Updated by Dominic Cleal almost 9 years ago

Incidentally, the host representation should not be returned in error messages since it contains password related attributes.

Actions #2

Updated by The Foreman Bot almost 9 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2309 added
  • Pull request deleted ()
Actions #3

Updated by Dominic Cleal almost 9 years ago

  • Assignee set to Daniel Lobato Garcia
Actions #4

Updated by Daniel Lobato Garcia almost 9 years ago

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

Updated by Marek Hulán almost 9 years ago

  • Related to Bug #9498: Unmanaged host name cannot be changed after NICs migration added
Actions

Also available in: Atom PDF