Bug 1324469

Summary: Unable to provision host without PXELinux template
Product: Red Hat Satellite Reporter: Roman Plevka <rplevka>
Component: OrchestrationAssignee: Lukas Zapletal <lzap>
Status: CLOSED ERRATA QA Contact: Roman Plevka <rplevka>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: bbuckingham, bkearney, ehelms, lzap, ohadlevy
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/14521
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:10:25 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:
Attachments:
Description Flags
both error messages displayed none

Description Roman Plevka 2016-04-06 12:05:37 UTC
Description of problem:
I wanted to provision a host on libvirt CR without PXELinux template (as libvirt guest machines already support iPXE). So i disassociated my OS from the PXELinux template. While creating a Host, the provsioning templates are correctly being resolved showing only:

finish Template Katello Kickstart Default Finish
iPXE Template Kickstart default iPXE
provision Template Katello Kickstart Default
user_data Template Katello Kickstart Default User Data

When I click submit I end up with error:
"Failed to generate PXELinux template: undefined method `encoding' for nil:NilClass"


Version-Release number of selected component (if applicable):
6.2.0 snap6.1

How reproducible:
always

Steps to Reproduce:
1. disassociate your OS from all PXELinux-type templates
2. Go to Operating Systems and make sure there's no PXELinux template field in the Templates tab of your OS
3. Create new host - make sure "Resolving Provisioning Templates" returns only the ones listed above (no PXELinux template)
4. Submit the form to start host provisioning.


Actual results:
"Failed to generate PXELinux template: undefined method `encoding' for nil:NilClass"

Expected results:
Host created/provisioned just fine

Additional info:

Comment 2 Lukas Zapletal 2016-04-06 12:50:45 UTC
TRIAGE NOTES: I don't think this is high-priority or blocker, easy workaround of associating any PXELinux template.

Comment 3 Lukas Zapletal 2016-04-07 09:56:57 UTC
Reproduced, we need to prevent from running TFTP orchestration.

2016-04-07 05:07:28 [app] [W] Failed to generate PXELinux template: undefined method `encoding' for nil:NilClass
 | NoMethodError: undefined method `encoding' for nil:NilClass
 | /opt/rh/rh-ruby22/root/usr/share/ruby/erb.rb:598:in `compile'
 | /opt/rh/rh-ruby22/root/usr/share/ruby/erb.rb:800:in `initialize'
 | /usr/share/foreman/lib/foreman/renderer.rb:16:in `new'
 | /usr/share/foreman/lib/foreman/renderer.rb:16:in `render_safe'
 | /usr/share/foreman/lib/foreman/renderer.rb:103:in `unattended_render'
 | /usr/share/foreman/app/models/concerns/orchestration/tftp.rb:45:in `generate_pxe_template'
 | /usr/share/foreman/app/models/concerns/orchestration/tftp.rb:63:in `setTFTP'
 | /usr/share/foreman/app/models/concerns/orchestration.rb:162:in `execute'
 | /usr/share/foreman/app/models/concerns/orchestration.rb:107:in `block in process'
 | /usr/share/foreman/app/models/concerns/orchestration.rb:99:in `each'
 | /usr/share/foreman/app/models/concerns/orchestration.rb:99:in `process'
 | /usr/share/foreman/app/models/concerns/orchestration.rb:35:in `on_save'

Comment 4 Bryan Kearney 2016-04-07 10:11:01 UTC
Upstream bug assigned to lzap

Comment 5 Bryan Kearney 2016-04-07 10:11:04 UTC
Upstream bug component is Orchestration

Comment 6 Lukas Zapletal 2016-04-07 12:00:33 UTC
For the record, this bug is only relevant in scenario when your OS *has* iPXE template associated but *has not* PXELinux template assicociate. If there is no iPXE, then we raise a proper error: "No %{template_kind} templates were found for this host, make sure you define at least one in your %{os} settings".

Before you verify, read the resolution in the upstream ticket. We are likely only to change the message to something better.

Comment 8 Bryan Kearney 2016-04-12 14:11:26 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/14521 has been closed
-------------
Lukas Zapletal
Applied in changeset commit:c7bb92a96c0ce8f8a9f6a3c4f2ce0bf95a73f459.

Comment 10 Lukas Zapletal 2016-05-16 09:57:34 UTC
I get your point, but we don't know that the host was created on libvirt. This part of Foreman must work in general, so I made a patch that gets rid of the ugly error "undefined method `encoding' for nil:NilClass" replacing it with a proper one. You need to associate at least PXELinux template.

For 6.3+ we will redesign PXE templates for UEFI support, I will consider an option to be able to avoid this behavior: https://github.com/theforeman/rfcs/pull/2#issuecomment-219390164

Comment 11 Roman Plevka 2016-05-20 15:17:19 UTC
(In reply to Lukas Zapletal from comment #10)
> I get your point, but we don't know that the host was created on libvirt.
> This part of Foreman must work in general, so I made a patch that gets rid
> of the ugly error "undefined method `encoding' for nil:NilClass" replacing
> it with a proper one. You need to associate at least PXELinux template.
> 
> For 6.3+ we will redesign PXE templates for UEFI support, I will consider an
> option to be able to avoid this behavior:
> https://github.com/theforeman/rfcs/pull/2#issuecomment-219390164

FAILEDQA:
This fix actually adds not message leaving the 'ugly' one still in place instead of replacing it. Could you tweak it more, please? [screenshot attached]

Comment 12 Roman Plevka 2016-05-20 15:18:16 UTC
Created attachment 1159981 [details]
both error messages displayed

Comment 13 Lukas Zapletal 2016-05-23 14:33:17 UTC
I don't see the upstream patch to be present:

https://github.com/theforeman/foreman/pull/3402/files

Comment 16 Lukas Zapletal 2016-06-07 12:41:25 UTC
I think the error message (see comment 12 screenshot) is clear enough. Compare to previous state which was only "Failed to generate PXELinux template: undefined method `encoding' for nil:NilClass". Now you see what's wrong and how to fix it.

Since we are redesigning TFTP orchestration for UEFI right now, I think this is not worth any other effort for 6.2. Required templates will be driven from TFTP flag that will be associated with host now (new feature).

Let's just waive it for 6.2. Workaround is obvious - either associate PXELinux template with our OS or don't associate TFTP Capsule for the whole subnet so TFTP orchestration is skipped.

Comment 19 Roman Plevka 2016-06-14 12:14:31 UTC
Moving to verified since showing both messages is apparently by design.

Comment 20 Bryan Kearney 2016-07-27 11:10:25 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