You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2020/07/01 10:29:11 UTC

[GitHub] [cloudstack] olivierlemasle opened a new issue #4191: Wrong count in listUsageRecords response

olivierlemasle opened a new issue #4191:
URL: https://github.com/apache/cloudstack/issues/4191


   ##### ISSUE TYPE
    * Bug Report
   
   ##### COMPONENT NAME
   ~~~
   API
   ~~~
   
   ##### CLOUDSTACK VERSION
   ~~~
   4.13
   4.14
   ~~~
   
   ##### CONFIGURATION
   N/A
   
   
   ##### OS / ENVIRONMENT
   N/A
   
   
   ##### SUMMARY
   The `count` in listUsageRecords reponse is wrong; it is equal to the number of usage records in the returned set (a single page), and not the total amount of usage records for a given request.
   
   This is a regression due to #3235 (specifically https://github.com/apache/cloudstack/pull/3235/commits/c0295ad20e19a2ddb0bfb7470220fbba17f41115).
   
   ##### STEPS TO REPRODUCE
   
   Query the listUsageRecords API, and look at the field "count".
   
   
   ##### EXPECTED RESULTS
   
   `count` is expected to be the total number of usage records with the specified filter.
   This is the behaviour for the other CloudStack API commands; a recent fix (#3894) was done to align with this behaviour, following issue #3890.
   
   With the wrong `count` value, an API user does not know if there's other pages in the result set.
   
   Actually, the same bug was already fixed back in 2013 with commit 78b1ac4126aa1d.
   
   ##### ACTUAL RESULTS
   
   ~~~
   $ cmk list usageRecords startdate=2020-07-01 enddate=2020-07-01 pagesize=10 page=1 | jq ".count"
   10
   ~~~
   
   #### Additional issue
   
   In the PR causing the issue (#3235), usage records of IP addresses on shared networks flagged "Hide IP address usage" were filtered out _after_ the search. I guess that's why the `count` value was updated. However, it also mean that the number of returned results in a page is not always equal to the `pagesize` parameter.
   
   E.g.: 
   ```
   $ cmk list usageRecords startdate=2020-07-01 enddate=2020-07-01 type=3 pagesize=10 page=25 | jq ".count"
   6
   $ cmk list usageRecords startdate=2020-07-01 enddate=2020-07-01 type=3 pagesize=10 page=26 | jq ".count"
   4
   $ cmk list usageRecords startdate=2020-07-01 enddate=2020-07-01 type=3 pagesize=10 page=27
   
   ```
   
   Here, 4 usage records were filtered on page 25.
   It is even possible to have **all** usages records filtered out on a page, which means that the result will be:
   
   ```json
   {"listusagerecordsresponse":{}}
   ```
   
   A page with all usage records filtered out is indistinguishable from a non-existing page (e.g. page 27 above), so there's absolutely no way to know how many pages must be fetched.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] olivierlemasle commented on issue #4191: Wrong count in listUsageRecords response

Posted by GitBox <gi...@apache.org>.
olivierlemasle commented on issue #4191:
URL: https://github.com/apache/cloudstack/issues/4191#issuecomment-652336708


   cc @rhtyd 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland closed issue #4191: Wrong count in listUsageRecords response

Posted by GitBox <gi...@apache.org>.
DaanHoogland closed issue #4191:
URL: https://github.com/apache/cloudstack/issues/4191


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] rhtyd commented on issue #4191: Wrong count in listUsageRecords response

Posted by GitBox <gi...@apache.org>.
rhtyd commented on issue #4191:
URL: https://github.com/apache/cloudstack/issues/4191#issuecomment-652375885


   Thanks for reporting @olivierlemasle 
   @Pearl1594 can you look into this, probably the fix is to use the count from the keypair that use size of the collection as total count.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on issue #4191: Wrong count in listUsageRecords response

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on issue #4191:
URL: https://github.com/apache/cloudstack/issues/4191#issuecomment-718116553


   addressed in #4193 , closing


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org