Bug 1113014

Summary: 500 ISE on creating a new host: Operation FAILED: can't convert nil into String
Product: Red Hat Satellite Reporter: Sachin Ghai <sghai>
Component: WebUIAssignee: Dmitri Dolguikh <ddolguik>
Status: CLOSED CURRENTRELEASE QA Contact: Sachin Ghai <sghai>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.3CC: dcleal, jmontleo, jsherril, sghai
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/6398
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1113292 (view as bug list) Environment:
Last Closed: 2014-07-02 14:04:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1113292    
Attachments:
Description Flags
host creation failed and Firebug raises 500 ISE
none
Logs from production.log
none
foreman-debug logs
none
requested stack trace from production.log after enabling debug logs
none
Logs from production.log with host create none

Description Sachin Ghai 2014-06-25 09:31:13 UTC
Created attachment 911999 [details]
host creation failed and Firebug raises 500 ISE

Description of problem:
I was trying to create a new host via UI and filled the form with all necessary info. But when I submit the form the firebug raised following error:

"NetworkError: 500 Internal Server Error - https://dhcp207-190.lab.eng.pnq.redhat.com/hosts/shost.katellolabs.org/vm"
vm
ReferenceError: _ is not defined

snippet from production.log 
============================
Processing by HostsController#vm as HTML
  Parameters: {"id"=>"shost.katellolabs.org"}
Operation FAILED: can't convert nil into String
  Rendered common/500.html.erb (10.2ms)
Completed 500 Internal Server Error in 46ms (Views: 15.4ms | ActiveRecord: 3.8ms)


Version-Release number of selected component (if applicable):
sat6 beta snap10 compose3

How reproducible:
tried once

Steps to Reproduce:
1. created new hostgroup and selected activation-key
2. filled up "New Host" form first with hostgroup and then unselect it
3. Filled all other details and submit the form

Actual results:
Processing by HostsController#vm as HTML
  Parameters: {"id"=>"shost.katellolabs.org"}
Operation FAILED: can't convert nil into String
  Rendered common/500.html.erb (10.2ms)
Completed 500 Internal Server Error in 46ms (Views: 15.4ms | ActiveRecord: 3.8ms)

Expected results:
host should be created successfully

Additional info:

Comment 1 Sachin Ghai 2014-06-25 09:32:39 UTC
Created attachment 912000 [details]
Logs from production.log

Comment 2 Sachin Ghai 2014-06-25 09:34:53 UTC
Created attachment 912001 [details]
foreman-debug logs

Comment 3 Dominic Cleal 2014-06-25 09:38:21 UTC
Please edit ~foreman/config/environments/production.rb and uncomment "config.log_level = :debug", run "service foreman restart" and retry to get a stack trace in the logs.

1. What type of compute resource are you provisioning onto?
2. If you visit the host page again, does it load correctly with power state?  i.e. is the bug only after initial provisioning

Comment 4 Sachin Ghai 2014-06-25 09:43:53 UTC
Looks like this issue is related to bz #1113012. As I stated in steps to reproduce, first I selected the hostgroup and then unselected. So looks like it was not unselected actually with empty row. 

I tried again with new host creation and without touching hostgroup dropdown. This time provisioning kicked off.

Comment 5 Sachin Ghai 2014-06-25 09:44:48 UTC
I'll share the requested info in comment3 in few minutes.

Comment 7 Sachin Ghai 2014-06-25 10:11:33 UTC
(In reply to Dominic Cleal from comment #3)
> Please edit ~foreman/config/environments/production.rb and uncomment
> "config.log_level = :debug", run "service foreman restart" and retry to get
> a stack trace in the logs.
> 
Please see attachment for traceback. 

> 1. What type of compute resource are you provisioning onto?
Libvirt

> 2. If you visit the host page again, does it load correctly with power
> state?  i.e. is the bug only after initial provisioning

On loading, All hosts page and selecting the failed VM, the state still shows "Loading Power state.." However, I can define a New Host

Comment 8 Sachin Ghai 2014-06-25 10:12:39 UTC
Created attachment 912018 [details]
requested stack trace from production.log after enabling debug logs

Comment 9 Dominic Cleal 2014-06-25 10:14:35 UTC
Could you provide the log including host creation?  This is only a partial bit.

Is the VM actually running?  I suspect it wasn't created.

Comment 10 Sachin Ghai 2014-06-25 10:27:51 UTC
I tried to check via virt-manager and it wasn't created. However UI shows its entry under "All hosts" with "Loading Power state..".

I'll try to re-create this issue and share the logs with host creation.

Comment 11 Sachin Ghai 2014-06-25 10:55:07 UTC
I can recreate the issue with following steps.

- Go to New Host page (Make sure one hostgroup already created)
- select hostgroup from drop down
- fill all details in form, I choose 'libvirt' compute resource
- de-select the selected hostgroup
- submit form


Going to attach complete logs with host_create in next comment.

Comment 12 Sachin Ghai 2014-06-25 10:55:52 UTC
Created attachment 912035 [details]
Logs from production.log with host create

Comment 13 Dominic Cleal 2014-06-25 11:23:46 UTC
There are a couple of odd things in both the latest log file and particularly the foreman-debug archive.  Are you getting an error when submitting the host, and then retrying?

The foreman-debug archive indicates a host creation that first fails with:

"Fetch TFTP boot files for shost.katellolabs.org task failed with the following error: invalid medium for RedHat 6.5"

And then a second attempt, which probably due to a bug in the form, is without the attributes required to create a new VM (I'd guess the "Virtual Machine" tab isn't visible when the form reloads).

(As a note to myself, validation of medium applicability to an OS should happen earlier too.)

Comment 14 Sachin Ghai 2014-06-25 11:38:31 UTC
(In reply to Dominic Cleal from comment #13)
> There are a couple of odd things in both the latest log file and
> particularly the foreman-debug archive.  Are you getting an error when
> submitting the host, and then retrying?
> 

Yes, initially when I deselected the hostgroup and submitted the form, I got following error. Since the Medium text box does not populated on UI when we select hostgroup, So when we unselect it, UI doesn't populate medium text box, it appears only on form submation and after below error.

Fetch TFTP boot files for shost1.katellolabs.org task failed with the following error: invalid medium for RedHat 6.5


> The foreman-debug archive indicates a host creation that first fails with:
> 
> "Fetch TFTP boot files for shost.katellolabs.org task failed with the
> following error: invalid medium for RedHat 6.5"
> 
Correct..

> And then a second attempt, which probably due to a bug in the form, is
> without the attributes required to create a new VM (I'd guess the "Virtual
> Machine" tab isn't visible when the form reloads).
> 
> (As a note to myself, validation of medium applicability to an OS should
> happen earlier too.)

Comment 15 Dominic Cleal 2014-06-25 11:41:28 UTC
Created redmine issue http://projects.theforeman.org/issues/6379 from this bug

Comment 16 Dominic Cleal 2014-06-25 11:56:06 UTC
Thanks for all of the logs and detail, that was a big help.

Note that the associated redmine is a tracker for two separate issues that are relevant here.

Comment 17 Bryan Kearney 2014-06-25 17:29:09 UTC
Upstream bug assigned to ddolguik

Comment 21 Sachin Ghai 2014-06-26 17:46:07 UTC
Verified with sat6 beta snap 11 compose2.

Could not reproduce the reported issue and can provision the host successfully.

Comment 22 Bryan Kearney 2014-07-02 14:04:54 UTC
This was delivered with 6.0.3, which is the Satellite 6 Beta.