Project

General

Profile

Bug #32464

Inherited hostgroup values are not set when creating host

Added by Hao Yu over 1 year ago. Updated 7 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Hosts
Target version:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

Description

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.

  1. 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

Associated revisions

Revision 23a5b7a7 (diff)
Added by Hao Yu over 1 year ago

Fixes #32464 - Inherited hostgroup values are not passed to host

History

#1 Updated by Hao Yu over 1 year ago

  • Difficulty set to easy
  • Category set to Hosts

#2 Updated by The Foreman Bot over 1 year ago

  • Assignee set to Hao Yu
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/9327 added

#3 Updated by Ian Ballou over 1 year ago

  • Triaged changed from No to Yes
  • Target version set to Katello 4.2.0

#4 Updated by The Foreman Bot over 1 year ago

  • Fixed in Releases Katello 4.2.0 added

#5 Updated by Hao Yu over 1 year ago

  • Status changed from Ready For Testing to Closed

#6 Updated by Jeremy Lenz over 1 year ago

  • Target version changed from Katello 4.2.0 to Katello 3.18.4

#7 Updated by Jonathon Turel over 1 year ago

  • Target version changed from Katello 3.18.4 to Katello 3.18.3

#8 Updated by The Foreman Bot 7 months ago

  • Pull request https://github.com/Katello/katello/pull/10108 added

Also available in: Atom PDF