Bug 1974656

Summary: [Rest API] Event search template filter throws SQL error
Product: [oVirt] ovirt-engine Reporter: Martin Necas <mnecas>
Component: RestAPIAssignee: Eli Mesika <emesika>
Status: CLOSED CURRENTRELEASE QA Contact: Guilherme Santos <gdeolive>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.4.7.3CC: bugs, dfodor, emesika, mperina
Target Milestone: ovirt-4.4.8Flags: pm-rhel: ovirt-4.4+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-engine-4.4.8 Doc Type: No Doc Update
Doc Text:
If this bug requires documentation, please select an appropriate Doc Type value.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-08-23 09:00:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Martin Necas 2021-06-22 09:07:08 UTC
Description of problem:
Hi,
when trying to search events in API/UI with template.name filter either returns an empty list or SQL error.

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


How reproducible:


Steps to Reproduce:
1. Request events with some specific template.name
2.
3.

Actual results:
Empty list or SQL error 

Expected results:
Filtred list of events

Additional info:

Comment 1 Eli Mesika 2021-06-27 23:39:38 UTC
search engine problem 

query generated :

SELECT * FROM ((
SELECT  distinct  audit_log.* 
FROM  audit_log   
LEFT OUTER JOIN vms_with_tags ON audit_log.vm_id=vms_with_tags.vm_guid    
LEFT OUTER JOIN vm_templates_storage_domain ON vms.vmt_guid=vm_templates_storage_domain.vmt_guid    <<<==== problem is here , vms.vmt_guid instead of vms_with_tags.vmt_guid, there is no vms view in this search query 
WHERE  vm_templates_storage_domain.name ILIKE 'a'  
AND not deleted)  ORDER BY audit_log_id DESC ) as T1 OFFSET (1 -1) LIMIT 100


related to : https://gerrit.ovirt.org/#/c/ovirt-engine/+/112551/ (not a regression but seems that this case of 2 LEFT OUTER JOIN was not covered with this fix)

probably corner case , first LEFT OUTER JOIN using vms_with_tags correctly while the second LEFT OUTER JOIN uses wrong vms instead of vms_with_tags