Description of problem: ---------------------- In 5.7.0.7, the chargeback cost is being computed as if a VM were used for 24 hours, even though it was used only for a few hours.See attached Chargeback report. In 5.6, the cost is computed for the duration for which the resource is in use. On 10/26/2016, we have 3 hourly rollups for the 'cu-24x7' VM running on vSphere 5.5. vmdb_production=# select cpu_usagemhz_rate_average from metric_rollups where resource_name = 'cu-24x7' and capture_interval_name = 'hourly' and timestamp < '10-27-2016'\x\g\x Expanded display is on. -[ RECORD 1 ]-------------+----------------- cpu_usagemhz_rate_average | 2685.44444444444 -[ RECORD 2 ]-------------+----------------- cpu_usagemhz_rate_average | 2674.81111111111 -[ RECORD 3 ]-------------+----------------- cpu_usagemhz_rate_average | 2675.01111111111 I have assigned the default chargeback rate.Here's the rate for CPU usage Fixed, Variable(USD/Mhz/hour) 0.0, 0.02 1)Based on my calculation, the Chargeback cost for cpu usage should be: Rate for the first hour + rate for the second hour + rate for the third hour = (2.68 GHz * 0.02) + (2.68 GHz* 0.02) + (2.68 GHz * 0.02) = (2.68 MHz * 1000 * 0.02) + (2.68 MHz * 1000 * 0.02) + (2.68 MHz * 1000 * 0.02) = 53.6 + 53.6 + 53.6 = 160.8 USD 2)The chargeback cost for CPU usage for this VM on 10/26/2016 is reported to be $1,285.64. 53.6 * 24 = 1285.64 USD So, it looks like although the VM was used only for 3 hours on 10/26/2016, the chargeback cost is being computed as if it were used for 24 hours. 3)On 10/27/2016 , the VM was powered on the whole day.The cost reported for CPU usage on 10/27 is about the same as the cost reported on 10/26. Version-Release number of selected component (if applicable): ------------------------------------------------------------ 5.7.0.7 How reproducible: ---------------- Always Steps to Reproduce: ------------------- 1.Manage a provider. 2.Enable C&U collection for the provider. 3.Collect C&U data for 2 days and then generate a chargeback report Actual results: --------------- VM chargeback cost computed as if VM were used for 24 hours, even though it was used for < 24 hours. Expected results: ---------------- Chargeback cost should be computed for the duration for which the resource was used. Additional info: ----------------
I spoke to John Hardy about this, he was in agreement that the behavior should not of changed to what it is today. Reopening and setting as a tentative blocker to 5.7 release.
Nandini, Sergio and I looked at this and we think that the value should be calculated as follows: avg CPU mhz for the day * variable rate * 24 hours And, avg CPU mhz for the day = the sum of the hourly values / 24 This is the calculation we'd expect. Which is very close to yours. The difference would be due to rounding. (2685.44444444444 + 2674.81111111111 + 2675.01111111111) / 24 * 0.02 * 24 = 160.70533333333321 We can't see why the report would have 1285.64 USD. Would you be able to provide access to the appliance or at least the DB so that we can investigate?
Merged to master: https://github.com/ManageIQ/manageiq/pull/12582
New commit detected on ManageIQ/manageiq/euwe: https://github.com/ManageIQ/manageiq/commit/f72936adb173609b4f1205dcf553c2c32d66d8aa commit f72936adb173609b4f1205dcf553c2c32d66d8aa Author: Gregg Tanzillo <gtanzill> AuthorDate: Mon Nov 14 16:27:23 2016 -0500 Commit: Oleg Barenboim <chessbyte> CommitDate: Tue Nov 15 09:59:51 2016 -0500 Merge pull request #12582 from lpichler/use_number_of_hours_in_interval_for_used_metrics Fix calculation of average for used metrics (cherry picked from commit 6e19aac6a06bc8d5712b8dd21dabfd2be70a79d4) https://bugzilla.redhat.com/show_bug.cgi?id=1390773 app/models/chargeback.rb | 2 +- app/models/chargeback_rate_detail.rb | 3 +- spec/models/chargeback_container_project_spec.rb | 44 ++++++++----- spec/models/chargeback_vm_spec.rb | 83 +++++++++++++++--------- 4 files changed, 83 insertions(+), 49 deletions(-)
Verified in 5.8.0.8