-
Notifications
You must be signed in to change notification settings - Fork 1.3k
api: Fix count and item issues returned by list APIs #3894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| response.setImageStores(imageStoreDao.listImageStores().size()); | ||
| response.setSystemvms(vmInstanceDao.listByTypes(VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm).size()); | ||
| response.setRouters(domainRouterDao.listAll().size()); | ||
| response.setRouters(domainRouterDao.listByRole(VirtualRouter.Role.VIRTUAL_ROUTER).size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pearl1594 calling listAll() i.e. getting all the rows will make the APIs slow in a large env; this is fine but can you explore a way to simply get the count (instead of the rows).
| response.setRouters(domainRouterDao.listAll().size()); | ||
| response.setRouters(domainRouterDao.listByRole(VirtualRouter.Role.VIRTUAL_ROUTER).size()); | ||
| response.setInternalLbs(domainRouterDao.listByRole(VirtualRouter.Role.INTERNAL_LB_VM).size()); | ||
| response.setAlerts(alertDao.listAll().size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above ^^ if it may be done quickly.
|
I'll test against Primate |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
rohityadavcloud
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, pending testing.
|
Test plan: cc @DaanHoogland @andrijapanicsb @borisstoyanov Verified on http://primate-qa.cloudstack.cloud:8080/client/master (this runs latest master + this PR)
Alerts, ilbvm keys:
|
|
Packaging result: ✖centos6 ✔centos7 ✔debian. JID-895 |
| allHostsPair = searchForServersExcluding(startIndex, pageSize, null, hostType, null, srcHost.getDataCenterId(), null, null, srcHostId, keyword, null, null, srcHost.getHypervisorType(), | ||
| srcHost.getHypervisorVersion()); | ||
| allHosts = allHostsPair.first(); | ||
| allHosts.remove(srcHost); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pearl1594 can you share why you add the method searchForServersExcluding ?
source host is removed in line
allHosts.remove(srcHost);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weizhouapache True, however, it was noticed that, say if there were 15 hosts, with a default pagesize of 10, the 1st page (considering it contained the src host) will have 9 objects returned and the 2nd page will have the remaining 5, as opposed to the ideal behavior of the 1st page containing 10 items and the remaining 4 being listed on page 2.
|
@blueorangutan test |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
| return suitablePools; | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pearl1594 curb adding newlines
rohityadavcloud
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested against Primate, and tested all the listed APIs per the test plan.
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✖centos6 ✔centos7 ✔debian. JID-896 |
|
@blueorangutan test |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✖centos6 ✔centos7 ✔debian. JID-897 |
|
@blueorangutan test |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
@rhtyd can you revert the commits related to list projects resource ? |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
tested with the following setting verified following apis results (2) list networks as root admin, (3) list routers as domain admin, (4) list resource as domain admin (5) list networks as domain admin (6) list resources as normal user (same as domain admin) (7) list networks as normal user (same as domain admin) |
|
@rhtyd @DaanHoogland @Pearl1594 If possible, please add a component/smoke test. |
|
@weizhouapache let me back to you on your comments soon, did you test/compare against 4.13/master? Wrt the listall=true&project-id change, this restricted to the root admin here: https://github.com/apache/cloudstack/pull/3894/files#diff-44c2e394637af1d7c556dac5575ba8d3R2683 Given this fix, there shouldn't be any change any non-admin accounts |
|
Trillian test result (tid-1107)
|
|
Thanks @weizhouapache I went through your test results, I've gathered a list of APIs that are only supported/affected by this PR for rest of the
Based on static code analysis and usages, only the following APIs are affected by the listall=true&projectid=-1 change and only for the root admin account type:
|
Signed-off-by: Rohit Yadav <[email protected]>
|
@weizhouapache I tried to look at git history, there was an attempt to fix similar issue for listVpcs #2352 but as a domain admin I'm still able to listVpcs of projects not owned/managed by the domain admin. I'll be updating http://primate-qa.cloudstack.cloud:8080/client/ shortly with this PR and carry tests on the APIs listed in previous comment (will tick those which passes excepted result). |
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
@rhtyd thanks for your update and quick fix ! |
|
Packaging result: ✖centos6 ✔centos7 ✔debian. JID-947 |
|
@blueorangutan test |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Quick test, for example the listing of ips: Before: (domain admin sees ips from other projects) After the fix: (domain admin only sees ips from their own projects) ... and the root admin is able to see everything: |
|
Trillian test result (tid-1117)
|
|
@weizhouapache are you satisfied that we can merge this? |
|
@DaanHoogland @andrijapanic can one of you review/test the final changes? |
|
@DaanHoogland @rhtyd I am ok with merging it. |
|
@andrijapanicsb, care to test? |
|
@DaanHoogland @andrijapanicsb I've tested apis mentioned in #3894 (comment) (see ticked) I think this is ready for merging once it passes one of your reviews/testings. |
|
If Rohit tested the security things, I'm fine with it. |
|
merging, assuming #3897 is there to remind us of the remaining issues @weizhouapache is asking for. |
|
Yes #3897 is to remind us to to system-wide survey/checks for all list APIs. |
Description
The count value returned in the APIs responses is incorrect
Allow listing of all resources for non-user accounts when listall=true and projectid=-1
listInfrastructure API to return count of internal LBs and Alerts in addition to the existing details returned
Addresses: #3890
Types of changes