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 1506253 - [Hammer] PG::Error while non-admin user listing entities in default location
Summary: [Hammer] PG::Error while non-admin user listing entities in default location
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Users & Roles
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: 6.4.0
Assignee: Ondřej Pražák
QA Contact: Peter Ondrejka
URL:
Whiteboard:
: 1491317 (view as bug list)
Depends On:
Blocks: 1373844
TreeView+ depends on / blocked
 
Reported: 2017-10-25 13:37 UTC by Jitendra Yejare
Modified: 2019-11-05 23:09 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-16 19:01:15 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 21871 0 None None None 2017-12-05 15:26:52 UTC
Red Hat Bugzilla 1622343 0 medium CLOSED Foreman (1.18?) slow API call against fact_values endpoint 2021-02-22 00:41:40 UTC

Internal Links: 1622343

Description Jitendra Yejare 2017-10-25 13:37:38 UTC
Description of problem:
PG Error when non-admin user attempt to list the entities(especially hostgroup, subnet, domain etc.) in the default location. Also, the default location is assigned to the user and its role.

Version-Release number of selected component (if applicable):
Satellite 6.3 snap 21

How reproducible:
Always

Steps to Reproduce:
1. Create role(in my case org admin role) with permissions to above entities listed in description
2. Assign default organization and location to that role
3. Create non admin user and assign above role
4. Assign default org and loc to above user
5. Attempt to list entities(especially subnet, domain etc.) from above user using hammer

Actual results:
#hammer subnet list --location-id 2
PG::Error: ERROR:  missing FROM-clause entry for table "locations_subnets"
LINE 1: ...ncestry" AS t1_r8, "taxonomies"."title" AS t1_r9, "locations...
                                                             ^
: SELECT "subnets"."id" AS t0_r0, "subnets"."network" AS t0_r1, "subnets"."mask" AS t0_r2, "subnets"."priority" AS t0_r3, "subnets"."name" AS t0_r4, "subnets"."vlanid" AS t0_r5, "subnets"."created_at" AS t0_r6, "subnets"."updated_at" AS t0_r7, "subnets"."dhcp_id" AS t0_r8, "subnets"."tftp_id" AS t0_r9, "subnets"."gateway" AS t0_r10, "subnets"."dns_primary" AS t0_r11, "subnets"."dns_secondary" AS t0_r12, "subnets"."from" AS t0_r13, "subnets"."to" AS t0_r14, "subnets"."dns_id" AS t0_r15, "subnets"."boot_mode" AS t0_r16, "subnets"."ipam" AS t0_r17, "subnets"."discovery_id" AS t0_r18, "subnets"."type" AS t0_r19, "taxonomies"."id" AS t1_r0, "taxonomies"."name" AS t1_r1, "taxonomies"."type" AS t1_r2, "taxonomies"."created_at" AS t1_r3, "taxonomies"."updated_at" AS t1_r4, "taxonomies"."ignore_types" AS t1_r5, "taxonomies"."description" AS t1_r6, "taxonomies"."label" AS t1_r7, "taxonomies"."ancestry" AS t1_r8, "taxonomies"."title" AS t1_r9, "locations_subnets"."id" AS t2_r0, "locations_subnets"."name" AS t2_r1, "locations_subnets"."type" AS t2_r2, "locations_subnets"."created_at" AS t2_r3, "locations_subnets"."updated_at" AS t2_r4, "locations_subnets"."ignore_types" AS t2_r5, "locations_subnets"."description" AS t2_r6, "locations_subnets"."label" AS t2_r7, "locations_subnets"."ancestry" AS t2_r8, "locations_subnets"."title" AS t2_r9, "smart_proxies"."id" AS t3_r0, "smart_proxies"."name" AS t3_r1, "smart_proxies"."url" AS t3_r2, "smart_proxies"."created_at" AS t3_r3, "smart_proxies"."updated_at" AS t3_r4, "smart_proxies"."pubkey" AS t3_r5, "smart_proxies"."expired_logs" AS t3_r6, "smart_proxies"."puppet_path" AS t3_r7, "smart_proxies"."download_policy" AS t3_r8, "dhcps_subnets"."id" AS t4_r0, "dhcps_subnets"."name" AS t4_r1, "dhcps_subnets"."url" AS t4_r2, "dhcps_subnets"."created_at" AS t4_r3, "dhcps_subnets"."updated_at" AS t4_r4, "dhcps_subnets"."pubkey" AS t4_r5, "dhcps_subnets"."expired_logs" AS t4_r6, "dhcps_subnets"."puppet_path" AS t4_r7, "dhcps_subnets"."download_policy" AS t4_r8, "dns_subnets"."id" AS t5_r0, "dns_subnets"."name" AS t5_r1, "dns_subnets"."url" AS t5_r2, "dns_subnets"."created_at" AS t5_r3, "dns_subnets"."updated_at" AS t5_r4, "dns_subnets"."pubkey" AS t5_r5, "dns_subnets"."expired_logs" AS t5_r6, "dns_subnets"."puppet_path" AS t5_r7, "dns_subnets"."download_policy" AS t5_r8 FROM "subnets" INNER JOIN "taxable_taxonomies" ON "taxable_taxonomies"."taxable_id" = "subnets"."id" AND "taxable_taxonomies"."taxable_type" = $1 INNER JOIN "taxonomies" ON "taxonomies"."id" = "taxable_taxonomies"."taxonomy_id" AND "taxonomies"."type" = $2 LEFT OUTER JOIN "taxable_taxonomies" "taxable_taxonomies_subnets_join" ON "taxable_taxonomies_subnets_join"."taxable_id" = "subnets"."id" AND "taxable_taxonomies_subnets_join"."taxable_type" = $3 LEFT OUTER JOIN "taxonomies" "organizations_subnets" ON "organizations_subnets"."id" = "taxable_taxonomies_subnets_join"."taxonomy_id" AND "organizations_subnets"."type" = $4 LEFT OUTER JOIN "smart_proxies" ON "smart_proxies"."id" = "subnets"."tftp_id" AND (smart_proxies.id IN (1,2)) LEFT OUTER JOIN "smart_proxies" "dhcps_subnets" ON "dhcps_subnets"."id" = "subnets"."dhcp_id" AND (smart_proxies.id IN (1,2)) LEFT OUTER JOIN "smart_proxies" "dns_subnets" ON "dns_subnets"."id" = "subnets"."dns_id" AND (smart_proxies.id IN (1,2)) WHERE (subnets.id IN (2)) AND ((("subnets"."id" IN (SELECT "subnets"."id" FROM         "subnets"
        INNER JOIN "taxable_taxonomies"
        ON "subnets"."id" = "taxable_taxonomies"."taxable_id"  AND taxable_type = 'Subnet' 
        INNER JOIN "taxonomies"
        ON "taxable_taxonomies"."taxonomy_id" = "taxonomies"."id" 
 WHERE "taxonomies"."id" = '1' )) AND ("subnets"."id" IN (SELECT "subnets"."id" FROM         "subnets"
        INNER JOIN "taxable_taxonomies"
        ON "subnets"."id" = "taxable_taxonomies"."taxable_id"  AND taxable_type = 'Subnet' 
        INNER JOIN "taxonomies"
        ON "taxable_taxonomies"."taxonomy_id" = "taxonomies"."id" 
 WHERE "taxonomies"."id" = '2' )))) AND (subnets.id IN (2)) AND "taxonomies"."type" IN ('Location') AND ("taxonomies"."id" = 2 OR "taxonomies"."title" = '2') AND "subnets"."id" IN (2)  ORDER BY vlanid, "taxonomies"."title" ASC, CASE WHEN "taxonomies"."title" = '2' THEN 1 ELSE 0 END

Expected results:
List of entities should be displayed without any error.

Additional info:

Comment 2 Marek Hulan 2017-10-25 13:48:51 UTC
The important part of the reproducer is that role must be assigned to location. After unassigning it works.

Comment 3 Ondřej Pražák 2017-12-05 15:26:50 UTC
Created redmine issue http://projects.theforeman.org/issues/21871 from this bug

Comment 4 Satellite Program 2017-12-11 11:18:38 UTC
Upstream bug assigned to oprazak

Comment 5 Marek Hulan 2017-12-11 14:03:03 UTC
I was able to reproduce on latest 6.3, the easy workaround seems to be

> hammer -u orgadmin -p changeme subnet list --search 'location_id = 2'

it's not fixed by the recent scoped_search fix (testing with 4.1.2). For some reason, it tries to load locations_subnets table so it ignores polymorphic association. I was also able to reproduce upstream.

Comment 6 Marek Hulan 2017-12-11 14:24:13 UTC
*** Bug 1491317 has been marked as a duplicate of this bug. ***

Comment 8 Satellite Program 2018-01-29 15:17:43 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21871 has been resolved.

Comment 9 Peter Ondrejka 2018-06-06 07:50:51 UTC
Verified on sat 6.4 snap 6

Comment 10 Bryan Kearney 2018-10-16 19:01:15 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, 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-2018:2927


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