Bug 2225129 - Satellite fails to perform kexec as a part of discovery process if no PXELoader is selected for the host profile
Summary: Satellite fails to perform kexec as a part of discovery process if no PXELoad...
Keywords:
Status: ASSIGNED
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Discovery Plugin
Version: 6.12.4
Hardware: All
OS: All
unspecified
medium
Target Milestone: Unspecified
Assignee: Leos Stejskal
QA Contact: addubey
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-07-24 11:08 UTC by Sayan Das
Modified: 2023-08-01 06:36 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 36626 0 Normal New Template render error when no PXELoader is selected 2023-08-01 06:36:58 UTC
Red Hat Issue Tracker SAT-19135 0 None None None 2023-07-25 11:25:37 UTC

Description Sayan Das 2023-07-24 11:08:21 UTC
Description of problem:

Satellite fails to perform kexec as a part of the discovery process if no PXELoader is selected for the host profile

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

Satellite 6.12.4 and later


How reproducible:

100%


Steps to Reproduce:

1. Install and configure a Satellite 6.12 for PXELess discovery-based deployment

2. Setup Hostgroups and discovery rules as per https://www.redhat.com/en/blog/provisioning-discovery-rules-red-hat-satellite-6 

3. Ensure that the PXELoader is unselected in the Hostgroup i.e. blank\nil.

4. You can use either Discovery ISO or boot the blank system from network to get the Discovery many and start booting from Discovery 

5. As soon as it shows the message about auto-discovery, hit some key to interrupt the process and then on the next screen, use DHCP or Static discovery options. 

   This interruption will ensure that kexec happens at the end.

6. Monitor the overall process. 



Actual results:

Host is discovered, a new host profile is created and submitted for build but kexec would not be possible due to the following traceback 

~~
2023-07-24T15:55:49 [W|app|75f82e89] Unable render or parse kexec template, must be valid JSON
2023-07-24T15:55:49 [I|app|75f82e89] Backtrace for 'Unable render or parse kexec template, must be valid JSON' error (NoMethodError): undefined method `include?' for nil:NilClass
 75f82e89 | Discovery Red Hat kexec:17:in `get_binding'
 75f82e89 | /usr/share/ruby/erb.rb:905:in `eval'
 75f82e89 | /usr/share/ruby/erb.rb:905:in `result'
 75f82e89 | /usr/share/foreman/app/services/foreman/renderer/unsafe_mode_renderer.rb:7:in `render'
 75f82e89 | /usr/share/foreman/app/services/foreman/renderer/base_renderer.rb:18:in `render'
 75f82e89 | /usr/share/foreman/app/services/foreman/renderer.rb:46:in `render'
 75f82e89 | /usr/share/foreman/app/models/template.rb:172:in `render'
 75f82e89 | /usr/share/foreman/app/models/host/base.rb:348:in `render_template'
 75f82e89 | /usr/share/gems/gems/foreman_discovery-21.0.5/app/models/host/managed_extensions.rb:48:in `render_kexec_template'
 75f82e89 | /usr/share/gems/gems/foreman_discovery-21.0.5/app/models/host/managed_extensions.rb:58:in `setKexec'
 75f82e89 | /usr/share/foreman/app/models/concerns/orchestration.rb:227:in `execute'
~~

Reason: The Hostgroup has no PXE Loader selected and hence Host also inherited a null value but https://github.com/theforeman/foreman/blob/develop/app/views/unattended/provisioning_templates/discovery/redhat_kexec.erb#L48 expects some loader to be selected so that it can search for the "SecureBoot" string. 

  extra << "--kexec-file-syscall" if @host.pxe_loader.include?('SecureBoot')


Expected results:

No such issues. Discovery Kexec should happen even if no PXELoaders are selected. 


Additional info:

We can solve it in two ways:

* Select the PXE Loader as "None" instead of leaving it blank. This allows both LEgacy BIOS and UEFI builds to happen without needing to specify any related loaders for the hostgroup or host.

* [ least preferable option i guess ] 

Change 

  extra << "--kexec-file-syscall" if @host.pxe_loader.include?('SecureBoot')

to

  extra << "--kexec-file-syscall" if @host.pxe_loader && @host.pxe_loader.include?('SecureBoot')


And then leaving the PXELoader blank\unselected will work.

[ But I still prefer to select None instead of this change ]

Comment 7 Leos Stejskal 2023-08-01 06:24:37 UTC
Looking at the issue, there are multiple ways how to fix the issue:
1) Show a warning in the UI that it should not be empty, unless the provisioning method is from an image.
This doesn't solve the issue of the API.
2) @host.pxe_loader should never return nil, always an empty array (best solution IMHO)
3) Documentation update.

And probably some other solutions.

I will create a PR fixing 2. point and let's see if it passes through the review,
then we should update the docs

Comment 8 Leos Stejskal 2023-08-01 06:36:57 UTC
Created redmine issue https://projects.theforeman.org/issues/36626 from this bug


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