Bug 1596157

Summary: Searching host in satellite with specific organization and location is not working as expected
Product: Red Hat Satellite Reporter: Ranjan Kumar <rankumar>
Component: HostsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED WONTFIX QA Contact: tstrych
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: aruzicka, inecas, tbrisker, vvasilev
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-02-03 16:29:49 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:
Attachments:
Description Flags
Steps none

Description Ranjan Kumar 2018-06-28 10:40:44 UTC
Created attachment 1455237 [details]
Steps

Description of problem: Search a host in a satellite with specific organization and location is not working as expected


Version-Release number of selected component (if applicable):6.3.0


How reproducible: Always


Steps to Reproduce:
1. Create organization org1 and location loc1
1. Create a host "host1" on satellite and assign org1 and loc1
3. Switch to any Context
4. Go to All hosts 
5. Try to locate host with a filter "organization=org1 and location=loc1"

Actual results: List 0 result


Expected results: It should list "host1"


Additional info: Workaround
Use filter "organization=org1 and location_id=<location-id>"

Comment 2 Adam Ruzicka 2018-08-13 12:48:17 UTC
This probably boils down to how scoped_search constructs the query. 

When I run the following in the rails console

Host.search_for('location = Somewhere and organization = Something').count

the SQL which gets executed is

SELECT COUNT(DISTINCT "hosts"."id") FROM "hosts"
       LEFT OUTER JOIN "taxonomies" ON "taxonomies"."id" = "hosts"."location_id" AND "taxonomies"."type" IN ('Location')
       LEFT OUTER JOIN "taxonomies" "organizations_hosts" ON "organizations_hosts"."id" = "hosts"."organization_id" AND "organizations_hosts"."type" IN ('Organization')
       WHERE "hosts"."type" IN ('Host::Managed') AND
             ((("taxonomies"."title" = 'Somewhere') AND ("taxonomies"."title" = 'Something')))

The part with taxonomies.title ensures this never matches any host, almost as if scoped search forgot that it renamed the second joined table as "organizations_hosts".

Opened an issue[1] at the scoped_search upstream repository.

[1] - https://github.com/wvanbergen/scoped_search/issues/180

Comment 3 Adam Ruzicka 2018-08-13 12:49:21 UTC
Created redmine issue http://projects.theforeman.org/issues/24594 from this bug

Comment 4 Bryan Kearney 2020-01-15 21:00:47 UTC
The Satellite Team is attempting to provide an accurate backlog of bugzilla requests which we feel will be resolved in the next few releases. We do not believe this bugzilla will meet that criteria, and have plans to close it out in 1 month. This is not a reflection on the validity of the request, but a reflection of the many priorities for the product. If you have any concerns about this, feel free to contact Red Hat Technical Support or your account team. If we do not hear from you, we will close this bug out. Thank you.

Comment 5 Bryan Kearney 2020-02-03 16:29:49 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.