Comment 6 for bug 1818671

Revision history for this message
Rodrigo Barbieri (rodrigo-barbieri2010) wrote :

I have this issue happening on two environments, one running 17.0.10 and the other running 17.0.11.

I have investigated this in more detail, and found out that the reason it does not show all projects is because there are more than 1000 instances to show. The Nova Tenant Usage API will not return more than 1000 results unless specified in nova.conf.

Increasing this value in nova.conf is not the best alternative for us as it will use more bandwidth and can hit the limit again. The ideal approach is to use pagination, since it is already implemented in this API for this purpose.

To use pagination, OpenStack CLI 3.19 or later needs to be used, and run the command:

$ openstack usage list --start 2019-08-01 --end 2019-08-31 --os-compute-api-version 2.40

However, running the above command hangs. Running again with --debug results in infinite loop doing queries, as follows:

1) The first query is

REQ: curl -g -i --cacert "xxx.crt" -X GET https://xxx:8774/v2/<admin-project-id>/os-simple-tenant-usage?start=2019-08-01T00:00:00&end=2019-08-31T00:00:00&detailed=1 -H "Accept: application/json" -H "OpenStack-API-Version: compute 2.40" -H "User-Agent: python-novaclient" -H "X-Auth-Token: xxx" -H "X-OpenStack-Nova-API-Version: 2.40"

2) it returns approximately 960 instances, the last instance id is fb23858a-b004-4367-a262-7adef90efac0 and has status "active".

3) The second query is

REQ: curl -g -i --cacert "xxx.crt" -X GET https://xxx:8774/v2/<admin-project-id>/os-simple-tenant-usage?start=2019-08-01T00:00:00&end=2019-08-31T00:00:00&marker=fb23858a-b004-4367-a262-7adef90efac0&detailed=1 -H "Accept: application/json" -H "OpenStack-API-Version: compute 2.40" -H "User-Agent: python-novaclient" -H "X-Auth-Token: xxx" -H "X-OpenStack-Nova-API-Version: 2.40"

4) The response is exactly the same as the first response.

5) Steps #3 and #4 go on forever.

The problem seems to be server-side as the CLI is behaving accordingly, but the API is ignoring the marker completely.