Bug 1633500

Summary: Web UI throws error when loading host facts page.
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: Host CollectionsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED WONTFIX QA Contact: Radovan Drazny <rdrazny>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.3CC: jalviso, shisingh
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-01 14:15:11 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:

Description Hao Chang Yu 2018-09-27 07:29:39 UTC
Description of problem:

Web UI throws the following error when non-admin user trying to load the facts page.

Oops, we're sorry but something went wrong Association named 'host_collections' was not found on Host::Base; perhaps you misspelled it?

This is happening when a user is attached to a role that contain a host filter that is limited by "host_collection"

How reproducible:
1) Create a host collection called 'test_HC'.
2) Add some hosts to 'test_HC'
3) Create a 'test' role
4) Add 'Host' resource type filter to the 'test' role.
5) Uncheck the "Unlimited?" box. Add "host_collection = test_HC" to the search.
6) Create a non-admin user and give it the 'test' role.
7) Login as the new user. Go to 'Hosts' -> 'All Hosts' -> Click any host -> Click 'Facts'


2018-09-27 17:27:15 80d4bda5 [app] [I] Processing by FactValuesController#index as HTML
2018-09-27 17:27:15 80d4bda5 [app] [I]   Parameters: {"host_id"=>"my-test-host.redhat.com"}
2018-09-27 17:27:15 80d4bda5 [app] [I] Current user: hyu (regular user)
2018-09-27 17:27:15 80d4bda5 [app] [D] Setting current user thread-local variable to hyu
2018-09-27 17:27:15 80d4bda5 [app] [I] Expire fragment views/tabs_and_title_records-4 (0.1ms)
2018-09-27 17:27:15 80d4bda5 [app] [D] Setting current location thread-local variable to bne
2018-09-27 17:27:15 80d4bda5 [app] [D] Setting current organization thread-local variable to hao_gss
2018-09-27 17:27:15 80d4bda5 [app] [D] Unpermitted parameter: host_id
2018-09-27 17:27:15 80d4bda5 [app] [D] Unpermitted parameter: host_id
2018-09-27 17:27:15 80d4bda5 [app] [D] Unpermitted parameter: host_id
2018-09-27 17:27:15 80d4bda5 [app] [D] Unpermitted parameter: host_id
2018-09-27 17:27:15 80d4bda5 [app] [I]   Rendered fact_values/index.html.erb within layouts/application (31.8ms)
2018-09-27 17:27:15 80d4bda5 [app] [W] Action failed
 | ActiveRecord::ConfigurationError: Association named 'host_collections' was not found on Host::Base; perhaps you misspelled it?
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/associations/join_dependency.rb:219:in `find_reflection'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/associations/join_dependency.rb:224:in `block in build'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/associations/join_dependency.rb:223:in `each'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/associations/join_dependency.rb:223:in `map'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/associations/join_dependency.rb:223:in `build'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/associations/join_dependency.rb:232:in `block in build'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/associations/join_dependency.rb:223:in `each'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/associations/join_dependency.rb:223:in `map'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/associations/join_dependency.rb:223:in `build'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/associations/join_dependency.rb:99:in `initialize'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation/query_methods.rb:1039:in `new'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation/query_methods.rb:1039:in `build_joins'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation/query_methods.rb:866:in `build_arel'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation/query_methods.rb:858:in `arel'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation.rb:639:in `exec_queries'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation.rb:515:in `load'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation.rb:243:in `to_a'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/will_paginate-3.1.5/lib/will_paginate/active_record.rb:126:in `block in to_a'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/will_paginate-3.1.5/lib/will_paginate/collection.rb:96:in `create'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/will_paginate-3.1.5/lib/will_paginate/active_record.rb:125:in `to_a'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation/delegation.rb:46:in `to_ary'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/partial_renderer.rb:404:in `collection_from_options'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/partial_renderer.rb:371:in `setup'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/partial_renderer.rb:293:in `render'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/renderer.rb:51:in `render_partial'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/renderer.rb:25:in `render'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/helpers/rendering_helper.rb:32:in `render'
 | /usr/share/foreman/app/views/fact_values/index.html.erb:27:in `_dddac68dbec96041d630d6dec7598855'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/template.rb:145:in `block in render'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activesupport-4.2.6/lib/active_support/notifications.rb:166:in `instrument'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/template.rb:333:in `instrument'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/template.rb:143:in `render'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/deface-1.2.0/lib/deface/action_view_extensions.rb:41:in `render'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activesupport-4.2.6/lib/active_support/notifications.rb:164:in `block in instrument'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activesupport-4.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/activesupport-4.2.6/lib/active_support/notifications.rb:164:in `instrument'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/template_renderer.rb:52:in `render_template'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/template_renderer.rb:14:in `render'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/renderer.rb:46:in `render_template'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/renderer/renderer.rb:27:in `render'
 | /opt/rh/rh-ror42/root/usr/share/gems/gems/actionview-4.2.6/lib/action_view/rendering.rb:100:in `_render_template'

Comment 2 Dustin Scott 2018-10-18 22:50:22 UTC
Just confirmed that this is working in 6.2.11.

+1 for this bug.  We are attempting to use host collections as a way to filter hosts out to limit Ansible Tower managed systems (limited licensing).

Also confirmed this is not working in 6.3.4 as well.

Comment 5 Bryan Kearney 2020-05-01 14:15:11 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.