-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/22339/
-----------------------------------------------------------

Review request for cloudstack and Kishan Kavala.


Bugs: CLOUDSTACK-6669
    https://issues.apache.org/jira/browse/CLOUDSTACK-6669


Repository: cloudstack-git


Description
-------

This patch fixes the remaining bug in the initial fix for CLOUDSTACK-6669.
See my example here: 
https://issues.apache.org/jira/browse/CLOUDSTACK-6669?focusedCommentId=14020334


Diffs
-----

  usage/src/com/cloud/usage/parser/VolumeUsageParser.java cd092a9 

Diff: https://reviews.apache.org/r/22339/diff/


Testing
-------

1. Create a DATA volume with "Custom Disk", size 1GB
2. Resize it to "Custom Disk", size 3GB
3. Resize it to "Custom Disk", size 20GB
4. Change disk offering to "Medium Disk, 20GB"
5. Check cloud_usage database:

mysql> select * from usage_volume where id = 9;
+----+---------+------------+-----------+------------------+-------------+-------------+---------------------+---------------------+
| id | zone_id | account_id | domain_id | disk_offering_id | template_id | size 
       | created             | deleted             |
+----+---------+------------+-----------+------------------+-------------+-------------+---------------------+---------------------+
|  9 |       1 |          2 |         1 |                6 |        NULL |  
1073741824 | 2014-06-07 07:00:01 | 2014-06-07 07:02:54 |
|  9 |       1 |          2 |         1 |                6 |        NULL |  
3221225472 | 2014-06-07 07:02:54 | 2014-06-07 07:26:40 |
|  9 |       1 |          2 |         1 |                6 |        NULL | 
21474836480 | 2014-06-07 07:26:40 | 2014-06-07 07:29:49 |
|  9 |       1 |          2 |         1 |                4 |        NULL | 
21474836480 | 2014-06-07 07:29:49 | NULL                |
+----+---------+------------+-----------+------------------+-------------+-------------+---------------------+---------------------+

and:

mysql> select description, raw_usage, offering_id, size, start_date, end_date 
from cloud_usage where usage_id=9 and usage_type = 6;
+-------------------------------------------+--------------------+-------------+-------------+---------------------+---------------------+
| description                               | raw_usage          | offering_id 
| size        | start_date          | end_date            |
+-------------------------------------------+--------------------+-------------+-------------+---------------------+---------------------+
| Volume Id: 9 usage time (DiskOffering: 6) | 0.0480558350682259 |           6 
|  1073741824 | 2014-06-07 06:55:00 | 2014-06-07 07:05:00 |
| Volume Id: 9 usage time (DiskOffering: 6) | 0.0350027792155743 |           6 
|  3221225472 | 2014-06-07 06:55:00 | 2014-06-07 07:05:00 |
| Volume Id: 9 usage time (DiskOffering: 6) |  0.166666939854622 |           6 
|  3221225472 | 2014-06-07 07:05:00 | 2014-06-07 07:15:00 |
| Volume Id: 9 usage time (DiskOffering: 6) |   0.16666667163372 |           6 
|  3221225472 | 2014-06-07 07:15:00 | 2014-06-07 07:25:00 |
| Volume Id: 9 usage time (DiskOffering: 6) | 0.0277749989181757 |           6 
|  3221225472 | 2014-06-07 07:25:00 | 2014-06-07 07:35:00 |
| Volume Id: 9 usage time (DiskOffering: 6) |  0.052500281482935 |           6 
| 21474836480 | 2014-06-07 07:25:00 | 2014-06-07 07:35:00 |
| Volume Id: 9 usage time (DiskOffering: 4) | 0.0863919407129288 |           4 
| 21474836480 | 2014-06-07 07:25:00 | 2014-06-07 07:35:00 |
+-------------------------------------------+--------------------+-------------+-------------+---------------------+---------------------+

We can see that usage records are duplicated when a volume has multiple sizes 
or multiple disk offerings on a given time range. Previously, usage records 
were aggregated, and size and offering_id were the values at the end of the 
period (see example 
https://issues.apache.org/jira/browse/CLOUDSTACK-6669?focusedCommentId=14020334)


Thanks,

Olivier Lemasle

Reply via email to