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 1953845 - Adding a hostgroup based search filter for "view_hosts" permission inside a custom role, breaks the Subnets and Domains page of Satellite 6 UI
Summary: Adding a hostgroup based search filter for "view_hosts" permission inside a c...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Users & Roles
Version: 6.9.0
Hardware: All
OS: Unspecified
unspecified
high
Target Milestone: 6.10.0
Assignee: satellite6-bugs
QA Contact: Peter Ondrejka
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-04-27 05:27 UTC by Sayan Das
Modified: 2021-11-16 14:10 UTC (History)
4 users (show)

Fixed In Version: foreman-2.5.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 14:10:44 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 32641 0 Normal Closed PG::AmbiguousColumn when listing domains 2021-06-04 17:40:04 UTC
Red Hat Product Errata RHSA-2021:4702 0 None None None 2021-11-16 14:10:50 UTC

Description Sayan Das 2021-04-27 05:27:35 UTC
Problem Description:

Adding a hostgroup based search filter for "view_hosts" permission inside a custom role breaks the Subnets and Domains page of Satellite 6 UI. Please check the reproducer steps to understand more.



Release Version of applicable components where this behavior was noticed:

Satellite 6.7, 6.8, 6.9



How Reproducible:

100%




Steps to Reproduce:


0. Ensure we have a subnet\domain\hostgroup present and one host associated with that hostgroup. For me, the hostgroup name is "capsule/RHEL8" which has a parent-child relationship but we can use a normal hostgroup as well.

1. From Administer --> Roles, Clone the "Viewer" role by the name "Custom Viewer"

2. Edit the "Custom Viewer" role, edit the view_hosts permission to add a search filter based on hostgroup_title i.e. hostgroup_title = capsule/RHEL8

	--> Optionally created a similar filter for "view_hostgroups" permission i.e. title = capsule/RHEL8  [ But this does not cause any harm and we can exclude it as well ]

3. Create a user and have the "Custom Viewer" role associated with the user.

4. Now login back to the UI with that User and visit the following pages.
	--> Hosts --> All Hosts
		  --> Content Hosts

	--> Infrastructure --> Subnets
			   --> Domains


5. Login back as admin and remove the search filter for view_hosts in the "Custom Viewer" role.

6. Now repeat the testing at Step 4 and everything will work fine.




Actual Results:


For the subnets page, the error will be,
~~
2021-04-27T09:02:29 [D|app|e9bcea08] Backtrace for 'Action failed' error (ActionView::Template::Error): PG::AmbiguousColumn: ERROR:  column reference "subnet_id" is ambiguous
LINE 1: SELECT COUNT(DISTINCT "hosts"."id") AS count_id, subnet_id A...
                                                         ^
: SELECT COUNT(DISTINCT "hosts"."id") AS count_id, subnet_id AS subnet_id FROM "hosts" INNER JOIN "nics" ON "nics"."host_id" = "hosts"."id" AND "nics"."primary" = $1 LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "hosts"."hostgroup_id" AND (hostgroups.id IN (1,2,3,4,5,6,7,8,9,10)) WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."organization_id" = $2 AND "hosts"."location_id" = $3 AND ((("hostgroups"."title" = 'capsule/RHEL8') AND ("hosts"."organization_id" = '1') AND ("hosts"."location_id" = '2'))) GROUP BY subnet_id
~~

For the domains page, the error will be,
~~
2021-04-27T09:03:19 [D|app|2f414de7] Backtrace for 'Action failed' error (ActionView::Template::Error): PG::AmbiguousColumn: ERROR:  column reference "domain_id" is ambiguous
LINE 1: SELECT COUNT(DISTINCT "hosts"."id") AS count_id, domain_id A...
                                                         ^
: SELECT COUNT(DISTINCT "hosts"."id") AS count_id, domain_id AS domain_id FROM "hosts" INNER JOIN "nics" ON "nics"."host_id" = "hosts"."id" AND "nics"."primary" = $1 LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "hosts"."hostgroup_id" AND (hostgroups.id IN (1,2,3,4,5,6,7,8,9,10)) WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."organization_id" = $2 AND "hosts"."location_id" = $3 AND ((("hostgroups"."title" = 'capsule/RHEL8') AND ("hosts"."organization_id" = '1') AND ("hosts"."location_id" = '2'))) GROUP BY domain_id

~~



Expected Results:

No errors are displayed and the user should be able to view the subnets and domains listed.



Additional Notes:
NA

Comment 4 Bryan Kearney 2021-05-28 10:18:36 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/32629 has been resolved.

Comment 6 Peter Ondrejka 2021-07-09 08:12:07 UTC
Verified on Satellite 6.10 sn 8 using steps from the problem description

Comment 9 errata-xmlrpc 2021-11-16 14:10:44 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 (Moderate: Satellite 6.10 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-2021:4702


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