Bug 1098183

Summary: Using dots in kickstart template names or hostgroups causes routing errors
Product: Red Hat Satellite Reporter: Nick Strugnell <nstrug>
Component: ProvisioningAssignee: jmagen <jmagen>
Status: CLOSED ERRATA QA Contact: Lukas Pramuk <lpramuk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.3CC: bbuckingham, bkearney, cwelton, dcleal, jmagen, jmontleo, kbidarka, omaciel, stbenjam, sthirugn
Target Milestone: UnspecifiedKeywords: Reopened, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/5826
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:00:58 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: 1126087, 1126937, 1220728, 1337931    
Bug Blocks:    

Description Nick Strugnell 2014-05-15 12:53:23 UTC
Description of problem:
Using dots in the names of kickstart templates or host groups results in problematic kickstart URLs in the default PXE configuration. 

Version-Release number of selected component (if applicable):
6.03

How reproducible:
Always

Steps to Reproduce:
1. Create a host group with a dot in the name
2. Create a kickstart with a dot in the name (NB we do not need dots in both the kickstart and host group name - either will cause a failure)
3. Associate the kickstart with the host group
4. Generate the PXE default menu by clicking the 'Build PXE Default' button
5. Go to /var/lib/tftpboot/pxelinux.cfg on the smartproxy and open the default file.
6. Paste the kickstart URL e.g. https://<servername>/foreman/unattended/template/testkickstart.1/test-1 into a browser window

Actual results:
A web message saying 'The page you were looking for doesn't exist'.

In production.log, we see: 

ActionController::RoutingError (No route matches [GET] "/unattended/template/testkickstart.1/test-1");



Expected results:
A rendered kickstart

Additional info:
This error occurs because the default Rails configuration uses dots as a separator for formatted routes, so doesn't accept them as part of dynamic segments.

A few suggested workaround:

1. Permit the use of dots in segments for the unattended controller.
2. Add contstraints to the UI to reject any template names or host group names containing dots as illegal.
3. Transparently map dots to underscores in the application.

Comment 1 RHEL Program Management 2014-05-15 12:55:10 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 RHEL Program Management 2014-05-15 15:25:18 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 4 Dominic Cleal 2014-05-20 14:47:53 UTC
Created redmine issue http://projects.theforeman.org/issues/5826 from this bug

Comment 5 jmagen@redhat.com 2014-05-25 11:51:47 UTC
fixed
https://github.com/theforeman/foreman/pull/1473

Comment 6 Bryan Kearney 2014-06-06 15:54:35 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/5826 has been closed

Comment 9 Kedar Bidarkar 2014-06-18 10:46:25 UTC
1. Created a host group with a dot in the name [new.host]
2. Created a kickstart with a dot in the name [Satellite Kickstart Default for RHEL.v2] which has content same as "Satellite Kickstart Default for RHEL"
3. Associated the kickstart template with the host group, via "provision templates" -> <template name> -> Association -> "Add Combination".
4. Generated the PXE default menu by clicking the 'Build PXE Default' button
5. Moved  to /var/lib/tftpboot/pxelinux.cfg on the smartproxy and opened the default file.
6. Tried accessing the link via the browser, https://dhcp201-170.englab.pnq.redhat.com/unattended/template/Satellite%20Kickstart%20Default%20for%20RHEL.v2/new.host

But get the below messsage,

"There was an error rendering the  template: undefined method 'info' for Hostgroup::Jail (Hostgroup)"


From the /var/log/foreman/production.log face the below issue.




Completed 200 OK in 73ms (Views: 50.7ms | ActiveRecord: 4.9ms)
Processing by UnattendedController#template as HTML
  Parameters: {"id"=>"Satellite Kickstart Default for RHEL.v2", "hostgroup"=>"new.host"}
  Rendered inline template (203.8ms)
  Rendered text template (0.0ms)
Completed 500 Internal Server Error in 217ms (Views: 0.5ms | ActiveRecord: 1.5ms)

ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'


Processing by UnattendedController#template as HTML
  Parameters: {"id"=>"Satellite Kickstart Default for RHEL.v2", "hostgroup"=>"new.host"}
  Rendered inline template (45.6ms)
  Rendered text template (0.0ms)
Completed 500 Internal Server Error in 55ms (Views: 0.6ms | ActiveRecord: 1.3ms)

ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'

Comment 10 Dominic Cleal 2014-06-24 15:55:00 UTC
That's a different bug, specifically with the template that's in use, it's not designed for host group-based provisioning.

Comment 11 jmagen@redhat.com 2014-07-06 08:04:11 UTC
Is this still a bug if the template is not designed for host group-based provisioning?

Comment 12 Dominic Cleal 2014-07-28 09:53:36 UTC
No needinfo required here, Joseph's question was answered in the redmine ticket.

Comment 13 Bryan Kearney 2014-08-12 12:47:40 UTC
Upstream bug assigned to stbenjam

Comment 14 Stephen Benjamin 2014-08-19 12:32:43 UTC
Moving back to MODIFIED, since the code for this specific bug is already merged downstream, and removing me from the assignee, since I don't have anything to do with this bug.

However, verifying this depends on a template enabled for host group provisioning.

1126087 provides one for Satellite. You'll need that to verify this.

Comment 15 Stephen Benjamin 2014-08-19 12:36:45 UTC
Also putting the URL back to the original one, this BZ is not 6363, which isn't even needed in Satellite - Katello templates had a separate issue, which was handled in 1126087.

Comment 17 Kedar Bidarkar 2015-03-16 12:42:46 UTC
This Bug cannot be verified till Bug : 1126087 is verified.

Tried with sat6.1 Beta snap6 compose2.

Comment 18 Kedar Bidarkar 2015-05-05 16:20:53 UTC
Currently host-group based provisioning templates cannot be rendered properly.

Comment 21 errata-xmlrpc 2015-08-12 05:08:38 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2015:1592

Comment 22 sthirugn@redhat.com 2015-08-14 20:43:09 UTC
Accidentally closed with 6.1.1 errata

Comment 25 Lukas Pramuk 2016-05-05 14:06:32 UTC
The described reproducer is blocked by BZ #1318732.

If anyone can provide different reproducer we can proceed and verify this BZ.

Comment 26 Lukas Pramuk 2016-05-05 14:23:27 UTC
Not really blocker, if we use chrome instead of firefox...

Comment 27 Lukas Pramuk 2016-05-05 15:50:22 UTC
BLOCKED by BZ # 1220728

@Sat6.2.0-Beta

Originally I wanted to FailQA but an error message is the same as with #BZ 1220728

FailedQA.

# awk '/append/{print$3}' /var/lib/tftpboot/pxelinux.cfg/default
ks=http://<SATFQDN>/unattended/template/Satellite%20Kickstart%20Default%20v2.0/RHEL7.2%20libvirt%20hosts

# wget http://<SATFQDN>/unattended/template/Satellite%20Kickstart%20Default%20v2.0/RHEL7.2%20libvirt%20hosts

production.log:

2016-05-05 10:54:35 [app] [I] Started GET "/unattended/template/Satellite%20Kickstart%20Default%20v2.0/RHEL7.2%20libvirt%20hosts" for 10.34.130.242 at 2016-05-05 10:54:35 -0400
2016-05-05 10:54:35 [app] [I] Processing by UnattendedController#hostgroup_template as HTML
2016-05-05 10:54:35 [app] [I]   Parameters: {"id"=>"Satellite Kickstart Default v2.0", "hostgroup"=>"RHEL7.2 libvirt hosts"}
2016-05-05 10:54:35 [app] [W] Action failed
 | NoMethodError: undefined method `content_facet' for #<Hostgroup:0x007f5d272e78c8>
 | /opt/rh/rh-ror41/root/usr/share/gems/gems/activemodel-4.1.5/lib/active_model/attribute_methods.rb:435:in `method_missing'

Comment 28 Lukas Pramuk 2016-06-06 14:46:23 UTC
VERIFIED.

@satellite-6.2.0-14.2.el7sat.noarch
foreman-1.11.0.34-1.el7sat.noarch

Reproducer:
1. create Hostgroup "My.Hostgroup" and associate it to Satellite Kickstart Default
2. Build PXE Default
3. # cat /var/lib/tftpboot/pxelinux.cfg/default
...
LABEL Satellite Kickstart Default - My.Hostgroup
     KERNEL boot/RedHat-6.8-x86_64-vmlinuz
     APPEND initrd=boot/RedHat-6.8-x86_64-initrd.img ks=http://<SATFQDN>/unattended/template/Satellite%20Kickstart%20Default/My.Hostgroup ksdevice=bootif network kssendmac
4. # curl http://<SATFQDN>/unattended/template/Satellite%20Kickstart%20Default/My.Hostgroup

/var/log/foreman/production.log:

2016-06-06 06:25:02 [app] [I] Started GET "/unattended/template/Satellite%20Kickstart%20Default/My.Hostgroup" for <CLIENT_IP> at 2016-06-06 06:25:02 -0400
2016-06-06 06:25:02 [app] [I] Processing by UnattendedController#hostgroup_template as HTML
2016-06-06 06:25:02 [app] [I]   Parameters: {"id"=>"Satellite Kickstart Default", "hostgroup"=>"My.Hostgroup"}
2016-06-06 06:25:02 [app] [I]   Rendered inline template (71.7ms)
2016-06-06 06:25:02 [app] [W] There was an error rendering the Unnamed template: 
 | ActionView::Template::Error: undefined method 'mac' for Hostgroup::Jail (Hostgroup)
 | /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.2.3/lib/safemode/jail.rb:17:in `method_missing'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.2.3/lib/safemode.rb:89:in `bind'


>>> ActionController::RoutingError (No route matches [GET] "/unattended/template/...) is fixed, hitting another error reported later (BZ # 1126937)

Comment 29 Lukas Pramuk 2016-06-06 14:52:09 UTC
The web message no longer says:
"The page you were looking for doesn't exist" (as was reported in this bug)

vs.

Now it says:
"There was an error rendering the Unnamed template: undefined method 'mac' for Hostgroup::Jail (Hostgroup)"

Comment 30 Bryan Kearney 2016-07-27 11:00:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1501