Bug 1534607 - Unable to use paging when searching for VMs available for specific user sorted by name
Summary: Unable to use paging when searching for VMs available for specific user sorte...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: RestAPI
Version: future
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: ovirt-4.2.2
: ---
Assignee: Ori Liel
QA Contact: Radim Hrazdil
URL:
Whiteboard:
Depends On:
Blocks: 1480877 1532186 1541255
TreeView+ depends on / blocked
 
Reported: 2018-01-15 14:46 UTC by biakymet
Modified: 2018-04-16 11:24 UTC (History)
5 users (show)

Fixed In Version: ovirt-engine-4.2.2.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-03-29 10:57:31 UTC
oVirt Team: Infra
rule-engine: ovirt-4.2+
rule-engine: blocker+


Attachments (Terms of Use)
Engine log produced by GET request. (1.30 KB, text/plain)
2018-01-15 14:46 UTC, biakymet
no flags Details


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 872147 unspecified CLOSED [RESTAPI] User API for search query don't filter result by specified parameter 2021-01-20 06:05:38 UTC
Red Hat Bugzilla 1163105 unspecified CLOSED [RFE] Supporting search in User-Level API 2021-01-20 06:05:38 UTC
Red Hat Bugzilla 1537735 unspecified CLOSED Unable to use paging when searching for VM pools available for specific user sorted by name 2021-01-20 06:05:38 UTC
oVirt gerrit 87256 master MERGED Support getting filtered, sorted vms with max results 2020-11-15 17:53:56 UTC
oVirt gerrit 87876 ovirt-engine-4.2 MERGED Support getting filtered, sorted vms with max results 2020-11-15 17:53:56 UTC

Internal Links: 872147 1163105 1537735

Description biakymet 2018-01-15 14:46:28 UTC
Created attachment 1381524 [details]
Engine log produced by GET request.

Description of problem:
URL: https://engine/ovirt-engine/api/vms/?search=SORTBY%20NAME%20ASC
Result: it return sorted VMs fine

URL: https://engine/ovirt-engine/api/vms/?max=8
Result: it return 8 VMs

URL: https://engine/ovirt-engine/api/vms/?max=8&search=SORTBY%20NAME%20ASC
Result: it return empty result

Version-Release number of selected component (if applicable):
Version 4.2.2-0.0.master.20180108193417.git45b0275.el7.centos


How reproducible:
100%

Steps to Reproduce:
1. Create two VMs
2. Use user other than admin
3. Set UserRole in that VMs for that user
4. Fire get request https://engine/ovirt-engine/api/vms/?max=1&search=SORTBY%20NAME%20ASC

Actual results:
Empty result

Expected results:
Sorted by name 1 VM

Comment 1 jniederm 2018-01-16 11:14:07 UTC
It applies to current master (commit 0427560272) as well. It reproduces even for admin@internal user. 'Filter: true' header has to be sent.

Comment 2 Ondra Machacek 2018-01-16 12:38:44 UTC
It works like this (swap the search and max):

 /api/vms?search=SORTBY NAME ASC&max=2

Comment 3 Ondra Machacek 2018-01-16 12:52:27 UTC
Oh, but it doesn't work for 'filter: true', I see.

Comment 4 jniederm 2018-01-17 00:28:10 UTC
My findings:
* Order of search and max query params doesn't matter. The problem appears in both cases.
* It appears even in 4.1 branch (commit 2591f4baa5)
* Steps to reproduce 2 (always use user admin@internal):
  1. make sure there are no vms in the engine
  2. create a vm called "vm"
  3. add a UserRole to it for admin@internal user
  4. create a template
  5. create a vm pool of 1 VM called "a-pool"
  6. create a vm pool of 1 VM called "z-pool"
  7. fire api request
     GET /api/vms?search=SORTBY NAME ASC&max=1
     Filter: true

  Actual result: <vms/>
* Possible cause:
  Method AbstractBackendCollectionResource#getBackendCollection(VdcQueryType, VdcQueryParametersBase, SearchType) executes two queries
  * GetAllVmsQuery that results all vms that a user has permission to. Results are trimmed to length of 'max' param.
  * SearchQuery that does filtering on name and applies limit and offset criteria.
  Result of the get request is a set intersection of results of these queries.
  In steps to reproduce 2 GetAllVmsQuery returns VM "vm" and SearchQuery may return a VM from a pool. Intersection of these results is empty.

Comment 5 jniederm 2018-01-17 10:44:52 UTC
Urgent because current (and only) VM portal can't reliably show VMs due to this bug.

Comment 6 Martin Perina 2018-01-24 09:07:51 UTC
Search engine is not usable with permissions and it would required complete redesign of it to allow that. That's why we decided to internally provide specialized query which is able to fetch VMs by name for specific user and provide paging support for it.

Comment 7 Yaniv Kaul 2018-02-18 15:48:07 UTC
Martin, we need this fix promptly. It blocks RHEV.TLV. When can we have it?

Comment 8 Martin Perina 2018-02-19 13:42:41 UTC
(In reply to Yaniv Kaul from comment #7)
> Martin, we need this fix promptly. It blocks RHEV.TLV. When can we have it?

It should be merged till tomorrow, but marking this one as a blocker for 4.2.2

Comment 9 Radim Hrazdil 2018-02-27 07:04:19 UTC
Verified by following steps in comment 4 and in the description for non-admin user.

RHV 4.2.2

Comment 10 Sandro Bonazzola 2018-03-29 10:57:31 UTC
This bugzilla is included in oVirt 4.2.2 release, published on March 28th 2018.

Since the problem described in this bug report should be
resolved in oVirt 4.2.2 release, it has been closed with a resolution of CURRENT RELEASE.

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


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