Bug 1511254

Summary: Host search using OR on facts finds duplicate records and takes a long time
Product: Red Hat Satellite Reporter: Manikandan Somasundaram <msomasun>
Component: SearchAssignee: Partha Aji <paji>
Status: CLOSED ERRATA QA Contact: Omkar Khatavkar <okhatavk>
Severity: high Docs Contact:
Priority: high    
Version: 6.2.12CC: akarsale, akhomic1, andrew.schofield, avroy, baitken, bkearney, gpadholi, kabbott, kgaikwad, mhulan, mmccune, pcreech, simon.bento
Target Milestone: 6.7.0Keywords: Reopened, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-14 13:22:23 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
BZ1511254.patch
none
Both 'OR' and 'AND' operators are working none

Description Manikandan Somasundaram 2017-11-09 00:33:21 UTC
Description of problem:
  
 AND and OR operation is not working on satellite as expected, when trying to filtering host with single filter like “facts.bios_vendor = SeaBIOS” it works fine, but when your try to filter using AND and OR operator its not working as expected, when filtering using AND it gives zero result “facts.bios_vendor = SeaBIOS and facts.architecture = x86_64”, when trying to filter using OR result is unstable as it gives around 1700 number of results even through there is only 10 machines registered with satellite.
  

How reproducible:
- Under Satellite UI - > Hosts → All Hosts → in search tab
- Try to filter host using any fact ex. “facts.bios_vendor = SeaBIOS”
- Also try to filter using any other fact ex. “facts.architecture = x86_64”
- Now combine search filter using AND and OR operator like below and check the result.
   Ex. “facts.bios_vendor = SeaBIOS and facts.architecture = x86_64”
   Ex. “facts.bios_vendor = SeaBIOS or facts.architecture = x86_64”

Actual results:
 - Observe there is no result when using AND operator
 - Observe there is N number of results when using OR operator which is regardless of number of registered clients.

Expected results:
- Should be able to search hosts using AND and OR

Additional info:
 Also tried to search using the query structure given on the link “https://github.com/wvanbergen/scoped_search/wiki/Query-language” but still result is not as expected.

Comment 1 Marek Hulan 2017-11-09 07:36:37 UTC
This works fine with 6.3, moving to ON_QA. Note that the variant with or does not make sense. That would find also hosts that have only bios vendor SeaBIOS and also different hosts which has architecture x86_64. So you could end up with SeaBIOS hosts with i386 arch.

The correct syntax is

> “facts.bios_vendor = SeaBIOS and facts.architecture = x86_64”

I could not find exact upstream fix but it might have changed by the scoped_search update.

Comment 6 Marek Hulan 2017-11-10 07:58:04 UTC
Created redmine issue http://projects.theforeman.org/issues/21625 from this bug

Comment 7 Satellite Program 2017-12-15 09:03:44 UTC
Upstream bug assigned to akarsale

Comment 8 Marek Hulan 2018-03-27 09:49:08 UTC
*** Bug 1560180 has been marked as a duplicate of this bug. ***

Comment 10 Bryan Kearney 2019-07-02 17:53:31 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.

Comment 12 Bryan Kearney 2019-09-03 19:06:57 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 13 Bryan Kearney 2019-09-05 12:55:08 UTC
Connecting redmine issue https://projects.theforeman.org/issues/25897 from this bug

Comment 14 Bryan Kearney 2019-09-05 14:04:18 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/25897 has been resolved.

Comment 15 Bryan Kearney 2019-09-05 14:35:28 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/25897 has been resolved.

Comment 17 Mike McCune 2019-11-12 17:29:26 UTC
Created attachment 1635451 [details]
BZ1511254.patch

Comment 18 Mike McCune 2019-11-12 17:31:43 UTC
*** Satellite 6.5.3 Patch ***

This bug will be resolved in 6.6 but if users wish to patch their 6.5 Satellite feel free to apply the attached patch.

1) Download BZ1511254.patch to your Satellite 6.5 Satellite

2) Copy to /usr/share/foreman/BZ1511254.patch

3) cd /usr/share/foreman

4) Patch: 

# patch -p1 < BZ1511254.patch 
patching file app/models/concerns/hostext/search.rb

5) restart

satellite-maintain service restart

Comment 19 Omkar Khatavkar 2019-11-29 10:20:52 UTC
Created attachment 1640632 [details]
Both 'OR' and 'AND' operators are working

Verified this on Satellite 6.7 with Snap 3. Both logical operators are working as expected

Comment 22 errata-xmlrpc 2020-04-14 13:22:23 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-2020:1454