Bug 1449290

Summary: Global PXE hostgroups menu entries missing when Installation Media is set to Synced Content
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: ProvisioningAssignee: Lukas Zapletal <lzap>
Status: CLOSED ERRATA QA Contact: Roman Plevka <rplevka>
Severity: high Docs Contact:
Priority: high    
Version: 6.5.0CC: bkearney, egolov, hmore, inecas, jcallaha, lzap, ofalk, pcreech
Target Milestone: 6.5.0Keywords: Reopened, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: https://github.com/theforeman/foreman/pull/4874
Whiteboard:
Fixed In Version: foreman-1.20.1.28-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-14 12:36:19 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:    
Bug Blocks: 1122832    
Attachments:
Description Flags
Proposed patch - foreman 1.15 none

Description Peter Vreman 2017-05-09 14:22:19 UTC
Description of problem:
When using Synced Content is set on a hostgroup it is not included in the Global PXE default menu.
The reason is that the medium_id is not set in case the Synced Content is used.




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


How reproducible:


Steps to Reproduce:
1. Create Hsotgroup and use Synced Content for Isntallation Media
2. Make sure that the Hostgroups have medium_id set to null
3. Alternative is to use the API to set the medium_id explicit to null
4. Create PXE default menu

Actual results:
Hostgroup that has Isntallation Media set to Sync Content (medium_id=null) is not included

Expected results:
Also Hostgroups with Isntallation Media on Synced Content

Additional info:

Comment 1 Peter Vreman 2017-05-09 14:22:43 UTC
--- /usr/share/foreman/app/models/provisioning_template.rb
+++ /usr/share/foreman/app/models/provisioning_template.rb
@@ -184,10 +184,10 @@
   # generated for
   def self.pxe_default_combos
     combos = []
-    ProvisioningTemplate.joins(:template_kind).where("template_kinds.name" => "provision").includes(:template_combinations => [:environment, {:hostgroup => [ :operatingsystem, :architecture, :medium]}]).each do |template|
+    ProvisioningTemplate.joins(:template_kind).where("template_kinds.name" => "provision").includes(:template_combinations => [:environment, {:hostgroup => [ :operatingsystem, :architecture]}]).each do |template|
       template.template_combinations.each do |combination|
         hostgroup = combination.hostgroup
-        if hostgroup and hostgroup.operatingsystem and hostgroup.architecture and hostgroup.medium
+        if hostgroup and hostgroup.operatingsystem and hostgroup.architecture and hostgroup.operatingsystem.medium_uri(hostgroup)
           combos << {:hostgroup => hostgroup, :template => template}
         end
       end

Comment 2 Peter Vreman 2017-05-09 17:07:35 UTC
Udpated patch to fix also the pxe_files() call that missed the Host paramter that is now neded to for Katello integration

--- /usr/share/foreman/app/models/provisioning_template.rb
+++ /usr/share/foreman/app/models/provisioning_template.rb
@@ -141,7 +141,7 @@
         tftp.create_default({:menu => menu})

         @profiles.each do |combo|
-          combo[:hostgroup].operatingsystem.pxe_files(combo[:hostgroup].medium, combo[:hostgroup].architecture).each do |bootfile_info|
+          combo[:hostgroup].operatingsystem.pxe_files(combo[:hostgroup].medium, combo[:hostgroup].architecture, combo[:hostgroup]).each do |bootfile_info|
             for prefix, path in bootfile_info do
               tftp.fetch_boot_file(:prefix => prefix.to_s, :path => path)
             end
@@ -184,10 +184,10 @@
   # generated for
   def self.pxe_default_combos
     combos = []
-    ProvisioningTemplate.joins(:template_kind).where("template_kinds.name" => "provision").includes(:template_combinations => [:environment, {:hostgroup => [ :operatingsystem, :architecture, :medium]}]).each do |template|
+    ProvisioningTemplate.joins(:template_kind).where("template_kinds.name" => "provision").includes(:template_combinations => [:environment, {:hostgroup => [ :operatingsystem, :architecture]}]).each do |template|
       template.template_combinations.each do |combination|
         hostgroup = combination.hostgroup
-        if hostgroup and hostgroup.operatingsystem and hostgroup.architecture and hostgroup.medium
+        if hostgroup and hostgroup.operatingsystem and hostgroup.architecture and hostgroup.operatingsystem.medium_uri(hostgroup)
           combos << {:hostgroup => hostgroup, :template => template}
         end
       end

Comment 4 Peter Vreman 2017-08-07 10:40:34 UTC
Updated patch to skip entries that had errors instead of failing with a generic useless error for the user

--- /usr/share/foreman/app/models/provisioning_template.rb
+++ /usr/share/foreman/app/models/provisioning_template.rb
@@ -141,7 +141,7 @@
         tftp.create_default({:menu => menu})

         @profiles.each do |combo|
-          combo[:hostgroup].operatingsystem.pxe_files(combo[:hostgroup].medium, combo[:hostgroup].architecture).each do |bootfile_info|
+          combo[:hostgroup].operatingsystem.pxe_files(combo[:hostgroup].medium, combo[:hostgroup].architecture, combo[:hostgroup]).each do |bootfile_info|
             for prefix, path in bootfile_info do
               tftp.fetch_boot_file(:prefix => prefix.to_s, :path => path)
             end
@@ -184,11 +184,17 @@
   # generated for
   def self.pxe_default_combos
     combos = []
-    ProvisioningTemplate.joins(:template_kind).where("template_kinds.name" => "provision").includes(:template_combinations => [:environment, {:hostgroup => [ :operatingsystem, :architecture, :medium]}]).each do |template|
+    ProvisioningTemplate.joins(:template_kind).where("template_kinds.name" => "provision").includes(:template_combinations => [:environment, {:hostgroup => [ :operatingsystem, :architecture]}]).each do |template|
       template.template_combinations.each do |combination|
         hostgroup = combination.hostgroup
-        if hostgroup and hostgroup.operatingsystem and hostgroup.architecture and hostgroup.medium
-          combos << {:hostgroup => hostgroup, :template => template}
+        if hostgroup and hostgroup.operatingsystem and hostgroup.architecture
+          begin
+            if hostgroup.operatingsystem.medium_uri(hostgroup)
+              combos << {:hostgroup => hostgroup, :template => template}
+            end
+          rescue => e
+            nil
+          end
         end
       end
     end

Comment 7 Lukas Zapletal 2017-09-22 15:42:51 UTC
Peter, thanks for the patches, they look good at first sight, would you mind filing them as PRs in our git repo:

https://github.com/theforeman/foreman

Our CI will perform unit tests and we can take it from there.

Comment 8 Peter Vreman 2017-09-25 11:57:19 UTC
Lukas,

Sorry my work only permits me to focus on using Sat6 in our environemnt. I have created patches to unblock my use cases where i was unable to create a workaround. For all patches i have created i have opened BZs and RedHat Cases.

Peter

Comment 9 Lukas Zapletal 2017-09-26 08:44:14 UTC
Sure, https://github.com/theforeman/foreman/pull/4874

Comment 10 Peter Vreman 2017-11-22 21:37:25 UTC
Created attachment 1357864 [details]
Proposed patch - foreman 1.15

Proposed patch for foreman 1.15

Comment 11 Peter Vreman 2017-11-22 21:40:37 UTC
Note that the patch also contains an additional rescue around the medium_uri call that might raise and exception sometimes. To prevent full abort of the PXE global menu generation i added the rescue block. Improvement might be to add an error/warning that the combo failed and is skipped.

Comment 12 Bryan Kearney 2018-11-30 15:01:00 UTC
The Satellite Team is attempting to provide an accurate backlog of bugzilla requests which we feel will be resolved in the next few releases. We do not believe this bugzilla will meet that criteria, and have plans to close it out in 1 month. This is not a reflection on the validity of the request, but a reflection of the many priorities for the product. If you have any concerns about this, feel free to contact Rich Jerrido or Bryan Kearney or your account team. If we do not hear from you, we will close this bug out. Thank you.

Comment 13 Peter Vreman 2018-12-03 16:03:29 UTC
Bryan,

Why is this being closed?
The default pxe menu is a faeture and this a BUG that prevents entries from being int he menu.

Secondly there is a patched attached to fix it!

For us this patch is a critical piece of our deployment workflow.

What do you need more than a patch for a BUG to get this fixed?


Peter

Comment 14 Bryan Kearney 2018-12-03 19:46:31 UTC
Thanks Peter. The bug was not connected to Redmine correctly, so it was not updated. I just checked and Lzap has already merged your patch and this will be in 6.5. I will do the appropriate steps now to make sure the bug reflects the current state.

Comment 15 Satellite Program 2018-12-03 19:47:14 UTC
Connecting redmine issue https://projects.theforeman.org/issues/21105 from this bug

Comment 16 Satellite Program 2018-12-03 19:48:31 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/21105 has been resolved.

Comment 17 Bryan Kearney 2019-01-04 13:08:55 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and while we recognize that it is a valid request, we do not expect this to be implemented in the product in the foreseeable future. This is due to other priorities for the product, and not a reflection on the request itself. We are therefore closing this out as WONTFIX. If you have any concerns about this, please do not reopen. Instead, feel free to contact Red Hat Technical Support. Thank you.

Comment 19 Bryan Kearney 2019-01-04 14:05:26 UTC
Bah.. missed this on my list. Moving back to ON_QA since it was delivered in Snap 7.

Comment 20 Oliver Falk 2019-01-04 14:38:35 UTC
Thx Bryan!

Oliver

Comment 21 Oliver Falk 2019-03-07 12:35:08 UTC
Hi!

Still the bug is seen in 6.5 HTB!

Thx,
 Oliver

Comment 22 Peter Vreman 2019-03-08 13:32:42 UTC
Patch against 6.5.0


---------
--- /usr/share/foreman/app/models/provisioning_template.rb
+++ /usr/share/foreman/app/models/provisioning_template.rb
@@ -208,18 +208,22 @@
   # generated for
   def self.pxe_default_combos
     combos = []
-    ProvisioningTemplate.joins(:template_kind).where("template_kinds.name" => "provision").includes(:template_combinations => [:environment, {:hostgroup => [ :operatingsystem, :architecture, :medium]}]).each do |template|
+    ProvisioningTemplate.joins(:template_kind).where("template_kinds.name" => "provision").includes(:template_combinations => [:environment, {:hostgroup => [ :operatingsystem, :architecture]}]).each do |template|
       template.template_combinations.each do |combination|
         hostgroup = combination.hostgroup
-        if hostgroup&.operatingsystem && hostgroup.architecture && hostgroup.medium
+        if hostgroup&.operatingsystem && hostgroup.architecture
           medium_provider = Foreman::Plugin.medium_providers.find_provider(hostgroup)
-          combos << {
-            :hostgroup => hostgroup,
-            :template => template,
-            :kernel => hostgroup.operatingsystem.kernel(medium_provider),
-            :initrd => hostgroup.operatingsystem.initrd(medium_provider),
-            :pxe_type => hostgroup.operatingsystem.pxe_type
-          }
+         if medium_provider
+            combos << {
+              :hostgroup => hostgroup,
+              :template => template,
+              :kernel => hostgroup.operatingsystem.kernel(medium_provider),
+              :initrd => hostgroup.operatingsystem.initrd(medium_provider),
+              :pxe_type => hostgroup.operatingsystem.pxe_type
+            }
+          else
+            Rails.logger.warn "Could not find medium_provider for hostgroup #{hostgroup}, skipping"
+          end
         end
       end
     end
------------

Comment 23 Bryan Kearney 2019-03-08 13:50:23 UTC
Lzap, can you take a look

Comment 25 Lukas Zapletal 2019-03-14 10:14:35 UTC
Hello, I have tested the patch and wrote tests for this case so it will not regress again. The PR is pending review: https://github.com/theforeman/foreman/pull/6570

Comment 32 Roman Plevka 2019-03-29 12:01:49 UTC
so, tested this on 6.5.0-20 and the HG menu entries are indeed created now (even for HG's that use the synced content).
I guess that's what verifies this BZ.



However, just for the record - the HG-based provisioning seems to be broken. First, there is a problem described in:

https://bugzilla.redhat.com/show_bug.cgi?id=1694048 - there is already a PR for this upstream, however, there is another problem:

https://projects.theforeman.org/issues/25753 which currently blocks the provisioning.

Comment 35 errata-xmlrpc 2019-05-14 12:36:19 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-2019:1222