Inaccurate showback calculation

It seems the showback calculation is inaccurate when vm is powerd off. I made a vm template with below properties:
CPU: 2
Memory: 2 GB
Disk: 12 GB (Using a 12GB disk image)

CPU Cost: 20
Memory Cost: 10
Disk: 30

Then I created a user (TestVDCUser, uid: 12) and made a vm (vm id: 12) from the mentioned template. After 1 hour I did the below commands:

[root@localhost ~]# onevm poweroff 12
[root@localhost ~]# oneshowback calculate -s $(date +"%F")
[root@localhost ~]# oneshowback list -u 12

Showback for 11/2020

USER_NAM GROUP_NA VM_ID VM_NAME MONTH YEAR HOURS COST
TestVDCU MehdiTes 12 Mehdi-Test-Show 11 2020 1.00 419.07

Calculating the user showback by hand show the opennebula calculated COST for the user is slightly the same as manual calculation:
(1021)+(2021)+(30121) = 420

Now that the vm is powerd off, we wiaited for another 1 hour to calculate the new user showback:

[root@localhost ~]# oneshowback calculate -s $(date +"%F")
[root@localhost ~]# oneshowback list -u 12

Showback for 11/2020

USER_NAM GROUP_NA VM_ID VM_NAME MONTH YEAR HOURS COST
TestVDCU MehdiTes 12 Mehdi-Test-Show 11 2020 2.00 837.90

Because the vm was powerd off along the next 1 hour, we expect just Disk cost will be applied in user cost. Then calculation for this time range shows:
3012(2.00-1.00) = 360

At the same time the cost increaded 418.83 (837.90-419.07) that is not what we expected (we expected 360)

The VM resources(cpu,ram,disk) are still reserved on the host when a VM is powered off so there is sort of a guarantee that the VM could be powered on again on the host.
You should use Undeploy to free the resources from the host and then the showback info should be as expected.

Hope this helps.

Anton Todorov

1 Like