Bug 1197975 - Error: undefined method `boot_filename' for nil:NilClass" on provisioning a discovered host via api's
Summary: Error: undefined method `boot_filename' for nil:NilClass" on provisioning a d...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: orabin
QA Contact: Sachin Ghai
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks: 1193977 1202240
TreeView+ depends on / blocked
 
Reported: 2015-03-03 06:19 UTC by Sachin Ghai
Modified: 2017-02-23 20:24 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-08-12 13:55:51 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
complete backtrace from production.log (15.73 KB, text/plain)
2015-03-03 06:19 UTC, Sachin Ghai
no flags Details
undefine method `boot_filename_error` when user submit the new host form without filling anything (18.64 KB, image/png)
2015-03-13 15:46 UTC, Sachin Ghai
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 9634 0 None None None 2016-04-22 16:23:38 UTC

Description Sachin Ghai 2015-03-03 06:19:55 UTC
Created attachment 997350 [details]
complete backtrace from production.log

Description of problem:
I was trying to provision a discovered host using rest api's. So listed the discovered host to get its id.

---
[root@dhcp207-190 fdi-image]# curl -i -k -u admin:changeme  -H "Accept: application/json" -X GET 'https://dhcp207-190.lab.eng.pnq.redhat.com/api/v2/discovered_hosts/'
HTTP/1.1 200 OK

Status: 200 OK
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8

{
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [{"name":"mac52540054c6e2","id":4,"ip":"192.168.100.11","mac":"52:54:00:54:c6:e2","last_report":"2015-03-03T05:55:53Z","subnet_id":1,"subnet_name":"libvirt","memory":995,"disk_count":1,"disks_size":8192,"cpus":1,"organization_id":1,"organization_name":"Default Organization","location_id":2,"location_name":"Default Location"}]
}
---

Next, I tried to provision it:

[root@dhcp207-190 fdi-image]# curl -i -k -u admin:changeme  -H "Content-Type: application/json" -X PUT 'https://dhcp207-190.lab.eng.pnq.redhat.com/api/v2/discovered_hosts/4'
HTTP/1.1 500 Internal Server Error

Status: 500 Internal Server Error
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8

{
  "error": {"message":"undefined method `boot_filename' for nil:NilClass"}
}

Version-Release number of selected component (if applicable):
Sat6.1 beta snap4 compose2
Satellite-6.1.0-RHEL-6-20150225.0

How reproducible:
always

Steps to Reproduce:
1. 
2.
3.

Actual results:
"error": {"message":"undefined method `boot_filename' for nil:NilClass"}
}


Expected results:
discovered host should be provisioned.

Additional info:

production.log:

Processing by Api::V2::DiscoveredHostsController#update as JSON
  Parameters: {"apiv"=>"v2", "id"=>"4", "discovered_host"=>{}}
Authorized user admin(Admin User)
undefined method `boot_filename' for nil:NilClass (NoMethodError)
/usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:60:in `dhcp_attrs'
/usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:16:in `dhcp_record'
/usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:140:in `dhcp_conflict_detected?'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:504:in `_run__2780850535898710428__validation__1886096933825684643__callbacks'

Comment 1 Lukas Zapletal 2015-03-04 12:13:27 UTC
Sachin,

your assumption that the host should be provisioned is not correct. You need to provide it some options (host group or individual options). In case when Operating System is not set, Foreman returns this ugly error.

Setting low priority, does not need to be in 6.1 GA.

Comment 2 Lukas Zapletal 2015-03-04 12:14:12 UTC
In other words: we will fix Foreman to return "Operating System was not set, cannot continue". Thus low priority.

Comment 3 Sachin Ghai 2015-03-04 12:49:22 UTC
Thanks Lukas.. yeah.. error should be user friendly.

Comment 5 Sachin Ghai 2015-03-13 15:46:46 UTC
Created attachment 1001434 [details]
undefine method `boot_filename_error` when user submit the new host form without filling anything

Comment 9 Bryan Kearney 2015-04-15 21:08:39 UTC
Bryan Kearney pushed to branch SATELLITE-6.1.0 at Satellite6 / foreman_discovery
46a9b568   Merge branch 'cherry-picks-2.0.1' into 'SATELLITE-6.1.0'
2ea063d7   refs #9546 - moving host_converter to proper directory for rails

Comment 10 Sachin Ghai 2015-04-28 11:58:52 UTC
Reported issue is still reproducible with:

sat6.1 GA snap1 compose 2 (Satellite-6.1.0-RHEL-7-20150424.0)


[root@cloud-qe-9 ~]# curl -k -u admin:changeme  -H "Content-Type: application/json" -X PUT 'https://cloud-qe-9.idmqe.lab.eng.bos.redhat.com/api/v2/discovered_hosts/3'
{
  "error": {"message":"undefined method `boot_filename' for nil:NilClass"}
}

Comment 11 orabin 2015-04-28 12:30:06 UTC
The compose is using a version of discovery prior to Bryan's merge.
The package needs to be rebuilt with the changes and then tested.
Moving to post until there is a new package.

Comment 13 Sachin Ghai 2015-05-05 13:15:52 UTC
Issue is still reproducible with sat6.1 GA Snap2 (Satellite-6.1.0-RHEL-7-20150429.2)

]# curl -k -u admin:changeme  -H "Content-Type: application/json" -X PUT 'https://dhcp201-172.englab.pnq.redhat.com/api/v2/discovered_hosts/2'
{
  "error": {"message":"undefined method `boot_filename' for nil:NilClass"}
}

Comment 14 Lukas Zapletal 2015-05-06 07:11:35 UTC
Just for clarifycation, you are sending invalid intput, there are some input data required. To fix this we need to:

- require discovered_host parameter in the docs
- programatially verify that hostgroup id is present OR all other parameters are present
- fix the boot_filename error in foreman core (I was under impression this was already fixed)

Comment 17 Ohad Levy 2015-05-13 11:58:58 UTC
new patch at https://github.com/theforeman/foreman/pull/2378

Comment 18 Lukas Zapletal 2015-05-18 08:48:50 UTC
Ori heads up - Bryan's bot is doing POST automatically. You need a downstream PR here.

Comment 22 Sachin Ghai 2015-05-21 13:22:29 UTC
Verified with sat6.1 GA snap5.

I can provision the discovered host via api and didn't see the reported issue:

 [root@ibm-x3550m3-06 pxelinux.cfg]# curl -i -k -u admin:changeme  -H "Accept: application/json" -X GET 'https://ibm-x3550m3-06.lab.eng.brq.redhat.com/api/v2/discovered_hosts/'
HTTP/1.1 200 OK
Date: Thu, 21 May 2015 13:10:33 GMT
Server: Apache/2.4.6 (Red Hat Enterprise Linux)
Foreman_version: 1.7.2
Foreman_api_version: 2
Apipie-Checksum: 555a0baaf6bde2915526836143b0e647
X-UA-Compatible: IE=Edge,chrome=1
Cache-Control: must-revalidate, private, max-age=0
X-Request-Id: ab26971a93accd64c2c886bb39c61a91
X-Runtime: 0.044195
X-Rack-Cache: miss
X-Powered-By: Phusion Passenger 4.0.18
Set-Cookie: _session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWZmOTllMDA1NGFiNmNjMTAwMDg5NTE0ZjExYzI3ZGIyBjsAVEkiC2xvY2FsZQY7AEZJIgdlbgY7AEY%3D--9927948ac6b7d346e4e304e6c9d6bdf795881664; path=/; secure; HttpOnly
ETag: "cc8805d3c6ba6320ecf4bdcdfdf06358"
Status: 200 OK
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8

{
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [{"name":"mac525400124a1e","id":3,"ip":"192.168.100.13","mac":"52:54:00:12:4a:1e","last_report":"2015-05-21T13:00:22Z","subnet_id":1,"subnet_name":"libvirt","memory":2003,"disk_count":1,"disks_size":8192,"cpus":2,"organization_id":1,"organization_name":"Default Organization","location_id":2,"location_name":"Default Location"}]
}

Comment 23 Sachin Ghai 2015-05-21 13:23:37 UTC
This time I got proper error instead of undefined method `boot_filename' for nil:NilClass" 

# curl -i -k -u admin:changeme  -H "Content-Type: application/json" -X PUT 'https://ibm-x3550m3-06.lab.eng.brq.redhat.com/api/v2/discovered_hosts/3'
HTTP/1.1 422 Unprocessable Entity
Date: Thu, 21 May 2015 13:11:20 GMT
Server: Apache/2.4.6 (Red Hat Enterprise Linux)
Foreman_version: 1.7.2
Foreman_api_version: 2
Apipie-Checksum: 555a0baaf6bde2915526836143b0e647
X-UA-Compatible: IE=Edge,chrome=1
Cache-Control: no-cache
X-Request-Id: f66f51c3b7c2c5e4eac2eb6334c5cdbd
X-Runtime: 0.602420
X-Rack-Cache: invalidate, pass
X-Powered-By: Phusion Passenger 4.0.18
Set-Cookie: _session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTM1NjE3NDJlOTZkNDY3YmY0YjYyZjljYzI0ODZhN2RiBjsAVEkiC2xvY2FsZQY7AEZJIgdlbgY7AEY%3D--5964d9a35fe3381518f123e083202dbb552ac2c2; path=/; secure; HttpOnly
Status: 422 Unprocessable Entity
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8

{
  "error": {"id":3,"errors":{"environment_id":["can't be blank"],"architecture_id":["can't be blank"],"operatingsystem_id":["can't be blank"],"domain_id":["can't be blank"],"root_pass":["should be 8 characters or more","should not be blank - consider setting a global or host group default"],"ptable_id":["can't be blank unless a custom partition has been defined"],"medium_id":["can't be blank"]},"full_messages":["Environment can't be blank","Architecture can't be blank","Operatingsystem can't be blank","Domain can't be blank","Root password should be 8 characters or more","Root password should not be blank - consider setting a global or host group default","Partition Table can't be blank unless a custom partition has been defined","Medium can't be blank"]}
}

Comment 24 Sachin Ghai 2015-05-21 13:24:38 UTC
Provisioning started as soon as I pass the hostgroup_id.

# curl -i -k -u admin:changeme  -H "Content-Type: application/json" -X PUT 'https://ibm-x3550m3-06.lab.eng.brq.redhat.com/api/v2/discovered_hosts/3' -d '{"hostgroup_id":1}'
HTTP/1.1 200 OK
Date: Thu, 21 May 2015 13:20:11 GMT
Server: Apache/2.4.6 (Red Hat Enterprise Linux)
Foreman_version: 1.7.2
Foreman_api_version: 2
Apipie-Checksum: 555a0baaf6bde2915526836143b0e647
X-UA-Compatible: IE=Edge,chrome=1
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: c670fcb81520212146054b7a110ec092
X-Runtime: 2.051427
X-Rack-Cache: invalidate, pass
X-Powered-By: Phusion Passenger 4.0.18
Set-Cookie: _session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTNiM2E2YTAxOTVkMDEwZjI2ZDhkZjVkZjAxMGY0MDhjBjsAVEkiC2xvY2FsZQY7AEZJIgdlbgY7AEY%3D--d6c540301f5fb191064908ba8790164dc093cc26; path=/; secure; HttpOnly
ETag: "180e176a576629592b4849bf39379148"
Status: 200 OK
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8

{"name":"mac525400124a1e.lab.eng.brq.redhat.com","id":3}

Comment 25 Bryan Kearney 2015-08-11 13:19:22 UTC
This bug is slated to be released with Satellite 6.1.

Comment 26 Bryan Kearney 2015-08-12 13:55:51 UTC
This bug was fixed in version 6.1.1 of Satellite which was released on 12 August, 2015.


Note You need to log in before you can comment on or make changes to this bug.