Bug 2225129

Summary: Satellite fails to perform kexec as a part of discovery process if no PXELoader is selected for the host profile
Product: Red Hat Satellite Reporter: Sayan Das <saydas>
Component: Discovery PluginAssignee: Leos Stejskal <lstejska>
Status: CLOSED MIGRATED QA Contact: Shweta Singh <shwsingh>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.12.4CC: addubey, jjansky, lstejska, pdudley, rlavi, shwsingh
Target Milestone: UnspecifiedKeywords: MigratedToJIRA, Regression, Triaged
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-06 16:25:10 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:

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

Comment 9 Eric Helms 2024-06-06 16:25:10 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.