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 1970623 - [BUG] Error Can't join 'Katello::ContentFacetRepository' to association named 'hostgroup' when clicking on "Errata Installation" inside a host_collection as a non-admin user
Summary: [BUG] Error Can't join 'Katello::ContentFacetRepository' to association named...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hosts - Content
Version: 6.9.0
Hardware: All
OS: Linux
high
high
Target Milestone: 6.12.0
Assignee: Partha Aji
QA Contact: Shweta Singh
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-06-10 20:04 UTC by Sayan Das
Modified: 2023-04-26 11:36 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-11-16 13:32:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 33940 0 Normal New Error Can't join 'Katello::ContentFacetRepository' to association named 'hostgroup' when clicking on "Errata Installatio... 2021-11-17 00:27:53 UTC
Red Hat Issue Tracker SAT-13317 0 None None None 2022-10-06 21:59:01 UTC
Red Hat Product Errata RHSA-2022:8506 0 None None None 2022-11-16 13:32:52 UTC

Internal Links: 2128422

Description Sayan Das 2021-06-10 20:04:14 UTC
Description of problem:

When accessing satellite as a non-admin user with custom roles configured, Host --> Host Collections --> Click on "Errata Installation" and it will show "There are no Errata associated with this Content Host to display."

And it will log the following error in the logs.

~~
ActiveRecord::ConfigurationError: Can't join 'Katello::ContentFacetRepository' to association named 'hostgroup'; perhaps you misspelled it?
~~

Version:

Satellite 6.9


How reproducible:
Always 

Steps to Reproduce:

1. Register a host with Satellite 6.9 and ensure it has some installable updates available.

2. Associate the host with a hostgroup named "Test" and host_collection name "Patch"

3. Create a custom role with following permissions and filters.
~~
----|-------------------------|------------------|------------|-----------|---------|---------------------------------------------------------------------------------
ID  | RESOURCE TYPE           | SEARCH           | UNLIMITED? | OVERRIDE? | ROLE    | PERMISSIONS                                                                     
----|-------------------------|------------------|------------|-----------|---------|---------------------------------------------------------------------------------
348 | JobInvocation           | none             | yes        | no        | ospatch | create_job_invocations, view_job_invocations                                    
350 | Host                    | hostgroup = Test | no         | no        | ospatch | view_hosts, edit_hosts                                                          
351 | Katello::HostCollection | none             | no         | no        | ospatch | view_host_collections, create_host_collections, edit_host_collections, destro...
353 | Location                | none             | no         | no        | ospatch | view_locations                                                                  
354 | Organization            | none             | no         | no        | ospatch | view_organizations                                                              
357 | Hostgroup               | name = Test      | no         | no        | ospatch | view_hostgroups, destroy_hostgroups                                             
----|-------------------------|------------------|------------|-----------|---------|---------------------------------------------------------------------------------

~~


4. Create a user called "Patch-Admin" and add the role "ospatch" to that user.

5. Login to satellite as "Patch-Admin" user and access Host --> Host Collections --> Patch --> Click on "Errata Installation"


Actual results:

In GUI --> "There are no Errata associated with this Content Host to display."

In production.log

~~
2021-06-11T00:14:26 [I|app|39d0c057] Started POST "/api/v2/hosts/bulk/installable_errata" for 10.74.X.X at 2021-06-11 00:14:26 +0530
2021-06-11T00:14:26 [I|app|39d0c057] Processing by Katello::Api::V2::HostsBulkActionsController#installable_errata as HTML
2021-06-11T00:14:26 [I|app|39d0c057]   Parameters: {"included"=>{"search"=>"host_collection_id = 1", "ids"=>[2]}, "paged"=>true, "page"=>"1", "per_page"=>"20", "search"=>"", "organization_id"=>"1", "api_version"=>"v2", "hosts_bulk_action"=>{"included"=>{"search"=>"host_collection_id = 1", "ids"=>[2]}, "paged"=>true, "page"=>"1", "per_page"=>"20", "search"=>"", "organization_id"=>"1"}}
2021-06-11T00:14:26 [E|app|39d0c057] ActiveRecord::ConfigurationError: Can't join 'Katello::ContentFacetRepository' to association named 'hostgroup'; perhaps you misspelled it?
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/associations/join_dependency.rb:201:in `find_reflection'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/associations/join_dependency.rb:206:in `block in build'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/associations/join_dependency.rb:205:in `each'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/associations/join_dependency.rb:205:in `map'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/associations/join_dependency.rb:205:in `build'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/associations/join_dependency.rb:69:in `initialize'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/query_methods.rb:1020:in `new'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/query_methods.rb:1020:in `construct_join_dependency'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/finder_methods.rb:373:in `apply_join_dependency'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder/relation_handler.rb:8:in `call'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder.rb:55:in `build'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder.rb:109:in `block in expand_from_hash'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder.rb:68:in `each'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder.rb:68:in `flat_map'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder.rb:68:in `expand_from_hash'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder.rb:70:in `block in expand_from_hash'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder.rb:68:in `each'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder.rb:68:in `flat_map'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder.rb:68:in `expand_from_hash'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/predicate_builder.rb:21:in `build_from_hash'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/where_clause_factory.rb:19:in `build'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/query_methods.rb:656:in `where!'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/relation/query_methods.rb:649:in `where'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.18.1.29/app/services/katello/applicable_content_helper.rb:45:in `installable_for_hosts'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.18.1.29/app/models/katello/erratum.rb:102:in `installable_for_hosts'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.18.1.29/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb:114:in `installable_errata'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionpack-6.0.3.4/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 39d0c057 | /opt/theforeman/tfm/root/usr/share/gems/gems/actionpack-6.0.3.4/lib/abstract_controller/base.rb:195:in `process_action'
~~


Expected results:

It should show the available errata's to install.



Additional info:

* I cannot reproduce this on Satellite 6.7.5. So it could be a regression.

* I can avoid this issue from happening on Satellite 6.9.2 if I removed the hostgroup based search_filters from the custom role.

* I doubt it has something to do with the introduction of katello_hostgroup_content_facets table since 6.9. Maybe something at code level is not properly mapped.

Comment 3 Partha Aji 2021-11-17 00:27:53 UTC
Connecting redmine issue https://projects.theforeman.org/issues/33940 from this bug

Comment 4 Bryan Kearney 2021-11-17 04:04:11 UTC
Upstream bug assigned to paji

Comment 5 Bryan Kearney 2021-11-17 04:04:12 UTC
Upstream bug assigned to paji

Comment 6 Bryan Kearney 2021-12-13 04:04:38 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/33940 has been resolved.

Comment 8 Silas Pusateri 2022-10-06 21:41:22 UTC
Verified
Version Tested: Satellite 6.12.0 snap 13
1. Register a host with Satellite 6.9 and ensure it has some installable updates available.

2. Associate the host with a hostgroup named "Test" and host_collection name "Patch"

3. Create a custom role with following permissions and filters.
~~
----|-------------------------|------------------|------------|-----------|---------|---------------------------------------------------------------------------------
ID  | RESOURCE TYPE           | SEARCH           | UNLIMITED? | OVERRIDE? | ROLE    | PERMISSIONS                                                                     
----|-------------------------|------------------|------------|-----------|---------|---------------------------------------------------------------------------------
348 | JobInvocation           | none             | yes        | no        | ospatch | create_job_invocations, view_job_invocations                                    
350 | Host                    | hostgroup = Test | no         | no        | ospatch | view_hosts, edit_hosts                                                          
351 | Katello::HostCollection | none             | no         | no        | ospatch | view_host_collections, create_host_collections, edit_host_collections, destro...
353 | Location                | none             | no         | no        | ospatch | view_locations                                                                  
354 | Organization            | none             | no         | no        | ospatch | view_organizations                                                              
357 | Hostgroup               | name = Test      | no         | no        | ospatch | view_hostgroups, destroy_hostgroups                                             
----|-------------------------|------------------|------------|-----------|---------|---------------------------------------------------------------------------------

~~


4. Create a user called "Patch-Admin" and add the role "ospatch" to that user.
5. Login to satellite as "Patch-Admin" user and access Host --> Host Collections --> Patch --> Click on "Errata Installation"
Results: The errata’s that are available to install are displayed

Comment 13 errata-xmlrpc 2022-11-16 13:32:43 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 (Important: Satellite 6.12 Release), 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-2022:8506


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