Bug 1454821

Summary: Search Query should not add the "IS NULL OR" part
Product: [oVirt] ovirt-engine Reporter: Elad <ebenahar>
Component: Search-BackendAssignee: Eli Mesika <emesika>
Status: CLOSED CURRENTRELEASE QA Contact: Radim Hrazdil <rhrazdil>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.2.0CC: bugs, ebenahar, mperina, tjelinek
Target Milestone: ovirt-4.2.0Keywords: Regression
Target Release: 4.2.0Flags: rule-engine: ovirt-4.2+
rule-engine: blocker+
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-20 11:32:53 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:
Bug Depends On:    
Bug Blocks: 1454389    
Attachments:
Description Flags
engine.log none

Description Elad 2017-05-23 14:02:23 UTC
Created attachment 1281564 [details]
engine.log

Description of problem:
Upon VM pool creation, all the VMs in the cluster get attached to the pool. An attempt to detach these VMs from the pool ends with 'User is not authorized to perform this action' error.

Version-Release number of selected component (if applicable):
ovirt-engine-4.2.0-0.0.master.20170517192237.git1e57f0c.el7.centos.noarch

How reproducible:
100%

Steps to Reproduce:
1. Have sone VMs in a cluster
2. Create a VM pool with several VMs 


Actual results:
All VMs in the cluster get attached to the newly created pool
can't detach them from the pool, hence, the pool is unremovable.

Expected results:
Only the VM pool should be attached to the pool.

Additional info:
engine.log


Pool creation:

2017-05-23 16:50:14,727+03 INFO  [org.ovirt.engine.core.bll.AddVmPoolCommand] (org.ovirt.thread.pool-6-thread-39) [7920e6c7-f0bd-4714-a51c-79df89d95948] Running command: AddVmPoolCommand int
ernal: false. Entities affected :  ID: a32b6b06-b948-491c-8e7a-20a29e56de66 Type: ClusterAction group CREATE_VM_POOL with role type USER,  ID: 1c7abfd7-9633-4f81-8f14-2e616c8a9f33 Type: VmTe
mplateAction group CREATE_VM with role type USER



Attempt to detach the VM:

2017-05-23 16:51:19,825+03 WARN  [org.ovirt.engine.core.bll.RemoveVmFromPoolCommand] (default task-31) [443fef29-24ad-4caa-bb92-4cdba0928fc8] Validation of action 'RemoveVmFromPool' failed f
or user admin@internal-authz. Reasons: USER_NOT_AUTHORIZED_TO_PERFORM_ACTION

Comment 1 Tomas Jelinek 2017-05-24 09:24:22 UTC
Im not sure the VMs are really attached to the pool. When checking our devel env it looks like only the VMPool->vms subtab is not filtering the VMs properly. 

Can you please check in DB:

select vm_name, vm_pool_id from vms;

what it returns?

Comment 2 Elad 2017-05-25 12:10:16 UTC
           vm_name           | vm_pool_id 
-----------------------------+------------
 golden_env_mixed_virtio_1_1 | 
 golden_env_mixed_virtio_2_0 | 
 golden_env_mixed_virtio_2_1 | 
 golden_env_mixed_virtio_3_0 | 
 golden_env_mixed_virtio_3_1 | 
 golden_env_mixed_virtio_1_0 | 
(6 rows)

Comment 3 Tomas Jelinek 2017-05-26 07:48:21 UTC
This is a regression in 4.2 introduced by https://gerrit.ovirt.org/#/c/69945/

The problem is that the pool subtab is using the following search query:
Vms : pool = somepool

Which translates into: 
SELECT * FROM ((SELECT distinct vms.* FROM  vms   WHERE  (vms.vm_pool_name IS NULL OR vms.vm_pool_name LIKE 'somepool') )  ORDER BY vm_name ASC ) as T1 OFFSET (1 -1) LIMIT 100

The key issue is the:
... vms.vm_pool_name IS NULL OR ...

e.g. it will return all VMs which are in no pool concatenated with VMs which are in in the requested pool.

This was not the case, the query previously did not have this IS NULL OR statement so it was returning only the requested VMs. The IS NULL OR has been introduced by https://gerrit.ovirt.org/#/c/69945/

Please note that this regression is also blocking the https://bugzilla.redhat.com/show_bug.cgi?id=1454389

Changing the title of this BZ and moving to infra.

Comment 4 Red Hat Bugzilla Rules Engine 2017-05-26 13:35:50 UTC
This bug report has Keywords: Regression or TestBlocker.
Since no regressions or test blockers are allowed between releases, it is also being identified as a blocker for this release. Please resolve ASAP.

Comment 5 Radim Hrazdil 2017-09-04 13:58:04 UTC
Verified that in 4.2.0-0.0.master.20170903205106.gitb17261a.el7.centos, after creating a pool, only vms belonging into that pool are shown.

Comment 6 Sandro Bonazzola 2017-12-20 11:32:53 UTC
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017.

Since the problem described in this bug report should be
resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.