Uploaded image for project: 'Satellite'
  1. Satellite
  2. SAT-25467

Fixes #36626 - safe checks for the pxe_loader

XMLWordPrintable

    • Moderate
    • No

      Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=2225129

      Steps to Reproduce:

      1. Install and configure a Foreman 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 ]

            rhn-engineering-lstejska Leos Stejskal
            rhn-engineering-lstejska Leos Stejskal
            Shubham Ganar Shubham Ganar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: