GutoVeronezi commented on a change in pull request #5517:
URL: https://github.com/apache/cloudstack/pull/5517#discussion_r786690487



##########
File path: 
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java
##########
@@ -368,7 +368,7 @@ public QuotaUsageVO updateQuotaDiskUsage(UsageVO 
usageRecord, final BigDecimal a
         QuotaTariffVO tariff = 
_quotaTariffDao.findTariffPlanByUsageType(QuotaTypes.CPU_NUMBER, 
usageRecord.getEndDate());
         if (tariff != null && 
tariff.getCurrencyValue().compareTo(BigDecimal.ZERO) != 0 && 
serviceoffering.getCpu() != null) {
             BigDecimal cpu = new BigDecimal(serviceoffering.getCpu());
-            onehourcostpercpu = 
tariff.getCurrencyValue().multiply(aggregationRatio);

Review comment:
       @sureshanaparti, actually, considering the global setting 
`usage.stats.job.aggregation.range` in the calculation turns it wrong. The 
global setting `usage.stats.job.aggregation.range` only defines the range 
between each record, but the raw usage is always inserted in hours.
   
   The `aggregationRatio` is defined by the `aggregationDuration` 
(`usage.stats.job.aggregation.range`) divided by `minutesInMonth` (43200). If 
the setting `usage.stats.job.aggregation.range` has `1440` (1 day) as value, 
the cost per hour will be `0.033333333`. Otherwise, if it has `60` (1 hour) as 
value, the cost per hour will be `0.001388889`. 
   
   Therefore, the lower the global setting `usage.stats.job.aggregation.range` 
is, the lower the cost per hour will be, which is incorrect, because the raw 
usage is always in hour.
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to