Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1955421 - Inherited hostgroup values are not set when creating host
Summary: Inherited hostgroup values are not set when creating host
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Host Group
Version: 6.9.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: 6.9.3
Assignee: satellite6-bugs
QA Contact: Tasos Papaioannou
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-04-30 05:41 UTC by Hao Chang Yu
Modified: 2024-10-01 18:04 UTC (History)
13 users (show)

Fixed In Version: tfm-rubygem-katello-3.18.1.30-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1962870 (view as bug list)
Environment:
Last Closed: 2021-07-01 14:56:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 32464 0 Normal New Inherited hostgroup values are not set when creating host 2021-04-30 07:17:42 UTC
Github Katello katello pull 9327 0 None open Fixes #32464 - Inherited hostgroup values are not passed to host 2021-04-30 07:20:59 UTC
Red Hat Issue Tracker SAT-18205 0 None None None 2023-06-07 15:09:31 UTC
Red Hat Knowledge Base (Solution) 6064921 0 None None None 2021-05-20 13:45:57 UTC
Red Hat Product Errata RHBA-2021:2636 0 None None None 2021-07-01 14:57:24 UTC

Description Hao Chang Yu 2021-04-30 05:41:56 UTC
Description of problem:
Failed to create a host using a nested hostgroup because all values that inherited from the parent host group are not set, such has content_view_id, content_source_id, lifecycle_environment_id and kickstart_repository_id.

Steps to Reproduce:
1. Create a parent hostgroup. Set the content source, content_view, lifecycle environment and the synced content.
2. Create a nested hostgroup that inherit the above values.
3. Create a host using the nested hostgroup.

hammer host create --name "my-test-client1" --hostgroup-id <the nested hostgroup id> --location "Default Location" --organization "MYORG" --mac="xx:xx:xx:xx:xx:xx" --domain-id 1  --ask-root-password yes --subnet apac-mps --ip xxx.xxx.xxx.xxx

Actual results:
Could not create the host:
  Medium can't be blank
  Content view can't be blank
  Lifecycle environment can't be blank


Expected results:
host created successfully

Additional info:
The "inherited_#{attribute}" method returns an array so rails is unable to set the nested attribute.


# foreman-rake console
Satellite 6.8 output: Hostgroup.find(21).inherited_kickstart_repository_id
=> 707   <========== Correct

Satellite 6.9 output: Hostgroup.find(21).inherited_kickstart_repository_id
=> [707]  <========= Wrong


Make the following change in "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.18.1.27/app/models/katello/concerns/hostgroup_extensions.rb" fixed the issue.

@@ -126,7 +126,7 @@
           facet_model = Facets.registered_facets[facet].hostgroup_configuration.model
           value = facet_model.where.not(attribute => nil).joins(:hostgroup).merge(
             ::Hostgroup.where(id: self.ancestor_ids).reorder(ancestry: :desc)
-          ).limit(1).pluck(attribute)
+          ).limit(1).pluck(attribute).first
         end
         value
       end

Comment 1 Bryan Kearney 2021-05-09 16:21:21 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/32464 has been resolved.

Comment 3 Tasos Papaioannou 2021-06-07 16:55:06 UTC
Verified on 6.9.3 snap 1.0.

1. Enable and sync Red Hat Enterprise Linux 7 Server Kickstart x86_64 7.9 (rhel-7-server-kickstart).
2. Create a parent hostgroup, selecting content source, content view, lifecycle environment, and Operating System fields.
3. Create a nested hostgroup that inherits those values from the parent hostgroup.
4. Create a host using the nested hostgroup:

# hammer host create --name test-host --hostgroup-id 2 --location-id 2 --organization-id 1 --mac '0e:05:fb:8f:22:d8'
Host created.

Comment 8 errata-xmlrpc 2021-07-01 14:56:48 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 (Satellite 6.9.3 Async Bug Fix Update), 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-2021:2636


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