You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Rohit Yadav <ro...@shapeblue.com> on 2015/03/16 11:10:33 UTC

[DISCUSS] Usage server: when can start end be after end date?

Hi,

In the usage server, when can a resource (say volumes) have their
creation date after end date when calculating usage records/data. For
example this check:

https://github.com/apache/cloudstack/blob/master/usage/src/com/cloud/usage/parser/VolumeUsageParser.java#L106

In which cases/scenarios, will we hit that?

Lastly, what happens if a resource usage is less than an aggregation
period or does not evenly divide into one. For example, if resource
usage were billed/generated hourly and if I use a VM for a 1.3 hours,
will I have usage data/records for an hour or 2 hours or 1.3 hours?

Regards,
Rohit Yadav
Software Architect, ShapeBlue
M. +91 8826230892 | rohit.yadav@shapeblue.com
Blog: bhaisaab.org | Twitter: @_bhaisaab
PS. If you see any footer below, I did not add it :)
Find out more about ShapeBlue and our range of CloudStack related services

IaaS Cloud Design & Build<http://shapeblue.com/iaas-cloud-design-and-build//>
CSForge – rapid IaaS deployment framework<http://shapeblue.com/csforge/>
CloudStack Consulting<http://shapeblue.com/cloudstack-consultancy/>
CloudStack Software Engineering<http://shapeblue.com/cloudstack-software-engineering/>
CloudStack Infrastructure Support<http://shapeblue.com/cloudstack-infrastructure-support/>
CloudStack Bootcamp Training Courses<http://shapeblue.com/cloudstack-training/>

This email and any attachments to it may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Shape Blue Ltd or related companies. If you are not the intended recipient of this email, you must neither take any action based upon its contents, nor copy or show it to anyone. Please contact the sender if you believe you have received this email in error. Shape Blue Ltd is a company incorporated in England & Wales. ShapeBlue Services India LLP is a company incorporated in India and is operated under license from Shape Blue Ltd. Shape Blue Brasil Consultoria Ltda is a company incorporated in Brasil and is operated under license from Shape Blue Ltd. ShapeBlue SA Pty Ltd is a company registered by The Republic of South Africa and is traded under license from Shape Blue Ltd. ShapeBlue is a registered trademark.

RE: [DISCUSS] Usage server: when can start end be after end date?

Posted by Kishan Kavala <Ki...@citrix.com>.
Response inline:

-----Original Message-----
From: Rohit Yadav [mailto:rohit.yadav@shapeblue.com] 
Sent: Monday, March 16, 2015 3:41 PM
To: dev
Cc: Kishan Kavala
Subject: [DISCUSS] Usage server: when can start end be after end date?

Hi,

In the usage server, when can a resource (say volumes) have their creation date after end date when calculating usage records/data. For example this check:

https://github.com/apache/cloudstack/blob/master/usage/src/com/cloud/usage/parser/VolumeUsageParser.java#L106

In which cases/scenarios, will we hit that?

[KK] Issue is due to the SQL query(GET_ALL_USAGE_RECORDS) in Usage**DaoImpl. If the usage job does not run for few days, records are processed in bulk when it runs the next time. In Vm usage for example, If there are multiple stop/starts during that period, usage_vm_instance will contain multiple entries for the same Vm. The last entry will have end_date = null if the Vm is still running. The entry with null end_date is always returned with this query irrespective of the start/end dates of the job. This may result in negative usage in some cases. Ideally this should be fixed in the Dao, instead of adding the check mentioned above. 

Lastly, what happens if a resource usage is less than an aggregation period or does not evenly divide into one. For example, if resource usage were billed/generated hourly and if I use a VM for a 1.3 hours, will I have usage data/records for an hour or 2 hours or 1.3 hours?

[KK] If the aggregation period is 1 hr, there will be two usage records X1 and X2. Raw_usage for X1 + X2 will = 1.3hrs. It could be 1hr in the 1st record and 0.3 hrs in the 2nd record. Depends on when the resource was allocated/released. It won't be 1hr or 2hrs for sure.