Problem with calculating server usage for given tenant/project

Bug #1719809 reported by Damian Kaliszan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
New
Undecided
Unassigned

Bug Description

Hi,
I'm trying to calculate servers usage for given project within a certain period of time. We have a special policy requiring calculating half of the resource usage between stop/start actions and none between shelve/unshelve so I have to calculate everything by hand and cannot fully rely on existing calculation methods.
I'm developed a simple script in python for this reason.
The thing/problem is:
1/ Firstly I'm trying to get a list of servers usage using nova.usage.get method for given period of time (let-s assume 2017-09-05 00:00:00 - 2017-09-09 23:59:59). The returned list isn't equivalent to nova.servers.list which seem to be ok at first glance. But it's not.
For given period of time from usage class I get a server with following info.
{ 'ended_at': '2017-09-05T13:08:59.000000',
    'flavor': '...',
    'hours': 1.3166666666666667,
    'instance_id': '...',
    'local_gb': 40,
    'memory_mb': ...,
    'name': 'SERVERNAME',
    'started_at': '2017-09-05T11:49:59.000000',
    'state': 'terminated',
    'tenant_id': '...',
    'uptime': 4740,
    'vcpus': 24}

It can be noticed this server ran for about 1 hour. For this reason I would like to check details and actions which are matching this server. So I ran nova.instance_action.list for this. The method is relevant to single command-liner (nova instance-action-list SERVERNAME) which returns:
ERROR (CommandError): No server with a name or ID of 'SERVERNAME' exists.

2/ Secondly, nova.servers.list returns me server which is not listed by nova.usage.get but it should have been. instance-action-list SERVERNAME returns the following actions on this one:
+----------+------------------------------------------+---------+----------------------------+
| Action | Request_ID | Message | Start_Time |
+----------+------------------------------------------+---------+----------------------------+
| create | ... | - | 2017-08-31T08:59:22.000000 |
| reboot | .... | - | 2017-08-31T09:20:13.000000 |
| shelve | ... | - | 2017-09-05T12:57:37.000000 |
| unshelve | ... | - | 2017-09-18T11:41:36.000000 |
| shelve | ... | - | 2017-09-18T12:31:30.000000 |
+----------+------------------------------------------+---------+----------------------------+

Why is this server not reported by usage.get method in provided period of time?It shoud return some info regarding this server but it's not. Isn't it a bug?
Alternatively - what am I doing wrong.....

Best,
Damian

Revision history for this message
Damian Kaliszan (damian1976) wrote :

One comment:
One of the questions is: Should I get list of servers for given project and period of time relying on what I get from nova.usage.get or nova.servers.list ? It may happend that in given period of time one of the servers will be shut down and will not appear on servers.list and thus I will not be able to check its instance-action-list (I will get error saying server with this name or id doesn't exist) to calculate shelve/unshelve and stop/start periods for further cost calculations. I hope I made myself clear and you see my point...
I think (maybe I'm missing that) there is lack of functionality allowing to ask for instance-action-list on DELETED servers......

Revision history for this message
Damian Kaliszan (damian1976) wrote :

I'm also trying with pure API via curl. With administrative rights I can list deleted servers but I cannot list actions for them. I get "Instance not found" error
curl -s -H "X-Auth-Token:MY_TOKEN" "https://openstack_url:8774/v2/TENANT_ID/servers/DELETED_SERVER_ID/os-instance-actions"
I also checked DB for that. Actions for this servers are properly existing in instance actions table...

Changed in python-novaclient:
status: New → In Progress
status: In Progress → New
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.