Project

General

Profile

Actions

Bug #5701

closed

Creating a host without OS set gives undefined method `boot_filename' exception

Added by Justin Bovee almost 10 years ago. Updated almost 6 years ago.

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

Description

Attached foreman-debug
Bug Trace: http://pastebin.com/YfR58LXG

CentOS release 6.5 (Final)

Versions
foreman-1.5.0-1.el6.noarch
ruby193-rubygem-foreman_discovery-1.3.0-0.1.rc2.el6.noarch
ruby193-rubygem-staypuft-0.0.12-1.el6.noarch

host was added through discovery process.
I attempted to use Staypuft to assign it as an OpenStack controller. It responded with "unassigned <hostname>"
Host no longer was listed under the discovery page but under the host page. Host was not managed.

Attempted to edit values on host or delete and received the error message.
Remove DHCP Settings for 14feb5200686 task failed with the following error: undefined method `boot_filename' for nil:NilClass/usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:60:in `dhcp_attrs'

Any assistance would be appreciated. Thank you!


Files

foreman-debug-oASL8.tar.xz foreman-debug-oASL8.tar.xz 475 KB Foreman-debug Justin Bovee, 05/13/2014 07:15 PM

Related issues 3 (0 open3 closed)

Related to Discovery - Tracker #8332: [Discovery 2.0] Usability alignment and autoprovisioningResolved11/10/2014

Actions
Related to Foreman - Bug #9634: Creating a host via API without OS set gives undefined method `boot_filename' exceptionClosedOri Rabin03/04/2015Actions
Is duplicate of Discovery - Bug #7724: foreman discovery bugDuplicate09/29/2014Actions
Actions #1

Updated by Lukas Zapletal almost 10 years ago

  • Project changed from Foreman to Discovery
  • Category set to Discovery plugin
  • Assignee set to Lukas Zapletal

Justin,

it looks like your host does not have Operating System assigned. This is required. Can you first make sure it has proper Operating System entry assigned and this Operatign System has all the required associations (templates, media etc)?

Then try to edit the host once again. Once we fix that, we need to find the way you managed to get into this state.

Actions #2

Updated by Lukas Zapletal almost 10 years ago

I just reproduced this one - develop branch. It blows up even when OS is set.

Actions #3

Updated by Lukas Zapletal almost 10 years ago

Greg, it looks like we are merging the parameters incorrectly, we need to get rid of the root "discover" element:

  Parameters: {"utf8"=>"✓", "authenticity_token"=>"MHEY/WxtPNYH+uHJ5sRYl6C+qsnYlfXBvv2Cl46ExM4=", "host"=>{"name"=>"52540039fb52", "hostgroup_id"=>"", "environment_id"=>"1", "puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "managed"=>"true", "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", "domain_id"=>"1", "realm_id"=>"", "mac"=>"52:54:00:39:fb:52", "subnet_id"=>"1", "ip"=>"192.168.122.186", "interfaces_attributes"=>{"new_interfaces"=>{"_destroy"=>"false", "type"=>"Nic::Managed", "mac"=>"", "name"=>"", "domain_id"=>"", "ip"=>"", "provider"=>"IPMI"}}, "architecture_id"=>"1", "provision_method"=>"build", "build"=>"1", "disk"=>"", "root_pass"=>"[FILTERED]", "is_owned_by"=>"1-Users", "enabled"=>"1", "model_id"=>"1", "comment"=>"", "overwrite"=>"false"}, "discover"=>{"puppetclass_ids"=>[""], "operatingsystem_id"=>"1", "medium_id"=>"1", "ptable_id"=>"7"}, "id"=>"52540039fb52"}

What caused the change?

Actions #4

Updated by Greg Sutcliffe almost 10 years ago

@lukas I can't replicate that at all - with latest HEAD of both foreman and discovery, the form renders all objects with host[] not discover[]

Actions #5

Updated by Lukas Zapletal almost 10 years ago

Greg, I just reproduced once again.

Just to put us on the same wave:

- discovered a random host
- on a discovered hosts page, clicked on Provision button
- New Host page appeared
- switched to Show Source browser feature
- search for "os_select" text
- this is what I see:

<span id="os_select">
    <div class="clearfix"><div class="form-group "><label class="col-md-2 control-label" for="operatingsystem_id">Operating system</label><div class="col-md-4"><select class="form-control " data-url="/os_selected_discovered_hosts" disabled="disabled" id="discovered_host_operatingsystem_id" name="discovered_host[operatingsystem_id]" onchange="os_selected(this);"><option value=""></option>
</select><span class="help-block"></span></div><span class="help-block help-inline"><img alt="Spinner" class="hide" src="/assets/spinner.gif" /></span></div></div>
</span>

Note the: name="discovered_host[operatingsystem_id]"

When I do New Host directly (clear case, no Discovered Hosts page involved), I see this correctly:

<span id="os_select">
  <div class="clearfix"><div class="form-group "><label class="col-md-2 control-label" for="operatingsystem_id">Operating system</label><div class="col-md-4"><select class="form-control " data-url="/hosts/os_selected" disabled="disabled" id="host_operatingsystem_id" name="host[operatingsystem_id]" onchange="os_selected(this);"><option value=""></option>
</select><span class="help-block"></span></div><span class="help-block help-inline"><img alt="Spinner" class="hide" src="/assets/spinner.gif" /></span></div></div>
</span>

Looking at the discovery/foreman code I think this naming is not correct.

This is my local gem set:

$ cat bundler.d/Gemfile.local.rb 
gem "facter" 
gem "pry-rails" 
gem "pry-plus" 

# plugins
gem 'foreman_discovery', :path => "../foreman_discovery/" 

Discovery: 5c524bb33caee8331e3ac3feac5633fb238910cc
Foreman: 7f7c531e3e35d30687aacb41ba00ebd04c2e0daf

Actions #6

Updated by Lukas Zapletal over 9 years ago

  • Is duplicate of Bug #7724: foreman discovery bug added
Actions #7

Updated by Frank Wall over 9 years ago

I have the same problem running Foreman 1.6.1 and discovery 1.4.0 RC4. It doesn't occur for all hosts, but I have at least two discovered hosts where the error is reproducable. When viewing the page source I can see the wrong name="discovered_host[operatingsystem_id]" too.

Please tell me if there is something I can do to trace the origin of this error.

Actions #8

Updated by Lukas Zapletal over 9 years ago

Frank, thanks for the report. Are you able to tell for which hosts do you enconter the error? I'd like to identify when it happens.

Actions #9

Updated by Frank Wall over 9 years ago

Lukas Zapletal wrote:

Frank, thanks for the report. Are you able to tell for which hosts do you enconter the error? I'd like to identify when it happens.

Unfortunately no. I was unable to find a scheme, it seems to happen for random hosts.

Actions #10

Updated by Lukas Zapletal over 9 years ago

  • Related to Tracker #8332: [Discovery 2.0] Usability alignment and autoprovisioning added
Actions #11

Updated by Lukas Zapletal over 9 years ago

Frank, can you please re-test with this image:

https://lzap.fedorapeople.org/temp/foreman-discovery-2.0pre1/

Actions #12

Updated by Lukas Zapletal over 9 years ago

I haven't confirmed yet, but user on IRC channel reports a workaround:

14:34 kick-buttowski | provision the machine with the ip that it booted from ( the discovery dhcpd ip )
14:34 kick-buttowski | and change it once you get a full host real quick ( before it get's built )
Actions #13

Updated by Frank Wall over 9 years ago

I guess I've found a way to reliable reproduce this error. You need to trigger a "Overwrite"-Condition, i.e. use an IP address or DNS name that is already in use. In this case foreman will notify about this problem and provide you with the "Overwrite" button. Once you click the button you will see the famous error: "undefined method `boot_filename' for nil:NilClass". You will also see the wrong parameters as described in comments 5 and 7.

Actions #14

Updated by Frank Wall over 9 years ago

@Lukas: Tested the new discovery image, but no change. I doubt that this bug is related to the discovery image.

Actions #15

Updated by Frank Wall over 9 years ago

The workaround from comment 12 does not work for me either. I still get the boot_filename error when trying to provision the discovered host.

Actions #16

Updated by Lukas Zapletal over 9 years ago

  • Related to Feature #8720: Add disable_dhcp_validations global setting added
Actions #17

Updated by Lukas Zapletal over 9 years ago

  • Project changed from Discovery to Foreman
  • Subject changed from undefined method `boot_filename' when attempting to change/delete host that was discovered to Creating a host without OS set gives undefined method `boot_filename' exception
  • Category changed from Discovery plugin to Web Interface
  • Priority changed from High to Normal

Okay this turns out to be bug in Foreman Core, nothing to do with Discovery. Steps to reproduce:

1) New Host (bare metal)
2) Do not use Host Group
3) Fill all the required parameters except OS
4) Submit, bang you have the error

Apparently OS is marked as required but it does not work and it proceeds with orchestration (where it fails during DHCP step).

Actions #18

Updated by Lukas Zapletal over 9 years ago

  • Project changed from Foreman to Discovery
  • Category changed from Web Interface to Discovery plugin

Update, it only happens when Discovery plugin is loaded ;-)

Actions #19

Updated by Lukas Zapletal over 9 years ago

I just reproduced it even without Discovery. I did select an architecture but nothing else on the OS tab! I am leaving the discovery project until we identify what is wrong.

Actions #20

Updated by Lukas Zapletal over 9 years ago

  • Project changed from Discovery to Foreman
  • Category changed from Discovery plugin to Orchestration

Ok I found the problem. Since our DHCP code is in our orchestration code that is triggered from a validator, it fails even when things were not set correctly:

From: /home/lzap/work/foreman/app/models/host/managed.rb @ line 152 Host::Managed#_callback_before_2313:

 => 152: validates :architecture_id, :presence => true, :if => Proc.new {|host| binding.pry; host.managed}

[1] pry(#<Host::Managed>)> host
=> #<Host::Managed id: nil, name: "test22.local.lan", ip: "192.168.122.25", last_compile: nil, last_freshcheck: nil, last_report: nil, updated_at: nil, source_file_id: nil, created_at: nil, mac: "c8:8e:78:53:c5:86", root_pass: "c8:8e:78:53:c5:86", serial: nil, puppet_status: 0, domain_id: 1, architecture_id: nil, operatingsystem_id: nil, environment_id: 1, subnet_id: 1, ptable_id: nil, medium_id: nil, build: true, comment: "", disk: "", installed_at: nil, model_id: nil, hostgroup_id: nil, owner_id: 1, owner_type: "User", enabled: true, puppet_ca_proxy_id: nil, managed: true, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: nil, puppet_proxy_id: nil, certname: nil, image_id: nil, organization_id: 3, location_id: 2, type: "Host::Managed", otp: nil, realm_id: nil, compute_profile_id: nil, provision_method: "build", primary_interface: nil, grub_pass: "", discovery_rule_id: nil>
[2] pry(#<Host::Managed>)> host.managed
=> true
[3] pry(#<Host::Managed>)> host.architecture_id
=> nil

When rails enconters a validation error, it continues with all the other validations. We need either to tell Rails to make the architecture/OS validations as fatal and not to continue or we need to fix the boot_filename method so it does not fail.

Actions #21

Updated by The Foreman Bot over 9 years ago

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

Updated by Frank Wall over 9 years ago

Hm. I've tested the patch from pull request 2026. It certainly fixes the boot_filename exception, but it doesn't solve the problem.

Once I try to use an IP/MAC where a DHCP/DNS entry already exists, Foreman prompts me to overwrite the old entry. When this happens, the parameter for operatingsystem gets lost, because it is again wrapped inside the discovery_host parameter:

"discovered_host"=>{"puppetclass_ids"=>[""], "operatingsystem_id"=>"9"}

This leads to a loop: I set the operating system again, click "Overwrite", and the operating system is once again empty...

Actions #23

Updated by Lukas Zapletal about 9 years ago

  • Pull request https://github.com/theforeman/foreman/pull/2120 added
  • Pull request deleted (https://github.com/theforeman/foreman/pull/2026)

Frank, I finally found the issue. Here is a patch for develop branch, it's few lines:

https://github.com/theforeman/foreman/pull/2120

Can you please try with Foreman stable and Discovery? Should work.

Actions #24

Updated by Lukas Zapletal about 9 years ago

  • Related to deleted (Feature #8720: Add disable_dhcp_validations global setting)
Actions #25

Updated by Lukas Zapletal about 9 years ago

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

Updated by Dominic Cleal about 9 years ago

  • translation missing: en.field_release set to 28
Actions #27

Updated by Lukas Zapletal about 9 years ago

  • Related to Bug #9634: Creating a host via API without OS set gives undefined method `boot_filename' exception added
Actions #28

Updated by Lukas Zapletal about 9 years ago

  • Bugzilla link set to 1202779
Actions

Also available in: Atom PDF