server: Fix resource count of primary storage/volume because of Expunged volumes#3669
Conversation
If the volume is in "Expunged" state then it should not be
considered towards total resource count of "primarystoragetotal"
field.
Currently cloudstack takes into resource calculation even if the
volume is expunged. The volume itself doesnt exist in primage
storage and hence it should not be considered towrds resource
caculation.
Steps to reproduce the issue:
1 . Get the resource count of "primarystoragetotal" of a particular domain.
2 . Create a VM with 5GB root disk size and stop it.
3 . Now the value of "primarystoragetotal" should be intitial value plus 5.
4 . Navigate to "volumes" of the VM and select "Download Volume" option.
5 . Once the volume is downloaded, expunge the VM.
6 . Get the resource count of "primarystoragetotal". it will be same value as in step 3
But it should be same as initial value obtained in step 1.
With this fix, the value obtained at step 6 will be same as in step 1.
weizhouapache
left a comment
There was a problem hiding this comment.
I can see volumes in Expunged state but not removed from database, by following the steps @rakgenius mentioned.
The volumes in Expunged state have been already removed from primary storage. They cannot be used anymore. It makes more sense not to take them into the recalculation of resource count of primary storage and volume.
The volumes in Expunged state will be cleaned up and removed from database when they have been removed from secondary storage. Please see
https://github.com/apache/cloudstack/blob/master/server/src/main/java/com/cloud/storage/StorageManagerImpl.java#L2389-L2392
This PR looks good to me. I have tested it.
|
@blueorangutan package |
|
@weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
@blueorangutan help |
|
@weizhouapache I understand these words: "help", "hello", "thanks", "package", "test" Blessed contributors for kicking Trillian test jobs: ['rhtyd', 'nvazquez', 'PaulAngus', 'borisstoyanov', 'DaanHoogland', 'anuragaw', 'shwstppr', 'andrijapanicsb', 'Spaceman1984'] |
|
Packaging result: ✖centos6 ✔centos7 ✔debian. JID-351 |
|
@rakgenius @weizhouapache makes perfect sense. Have you looked at the usage server and billing verification? This could be needed if events don't get logged for the volumes. |
|
@rhtyd @DaanHoogland @andrijapanicsb can you kick off a test ? by the way, is it possible to grant me access to kick a test ? |
|
@weizhouapache I am afraid not, These tests are run in our internal lab and we need to keep small degree of control on how busy we let it get. |
|
@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-502)
|
|
The PR has two approvals , and BO tests passed. |
|
@weizhouapache I am looking at the travis run; once again a maximum log length error. I restarted it just to see. I am awaiting it but I think we are good to go. |
If the volume is in "Expunged" state then it should not be
considered towards total resource count of "primarystoragetotal"
field.
Currently cloudstack takes into resource calculation even if the
volume is expunged. The volume itself doesnt exist in primage
storage and hence it should not be considered towrds resource
caculation.
Steps to reproduce the issue:
1 . Get the resource count of "primarystoragetotal" of a particular domain.
2 . Create a VM with 5GB root disk size and stop it.
3 . Now the value of "primarystoragetotal" should be intitial value plus 5.
4 . Navigate to "volumes" of the VM and select "Download Volume" option.
5 . Once the volume is downloaded, expunge the VM.
6 . Get the resource count of "primarystoragetotal". it will be same value as in step 3
But it should be same as initial value obtained in step 1.
With this fix, the value obtained at step 6 will be same as in step 1.
Description
If the volume of a VM is in "Expunged" state then it should not be
considered towards total resource count of "primarystoragetotal"
field of a domain.
Currently, CloudStack takes into resource calculation even if the
volume is expunged. The volume itself doesn't exist in primary
storage and hence it should not be considered towards resource
calculation.
Steps to reproduce the issue:
1 . Get the resource count of "primarystoragetotal" of a particular domain.
2 . Create a VM with 5GB root disk size and stop it.
3 . Now the value of "primarystoragetotal" should be intitial value plus 5.
4 . Navigate to "volumes" of the VM and select "Download Volume" option.
5 . Once the volume is downloaded, expunge the VM.
6 . Get the resource count of "primarystoragetotal". it will be same value as in step 3
But it should be same as initial value obtained in step 1.
Types of changes
Screenshots (if appropriate):
How Has This Been Tested?
This has been tested using the cloudmonkey api commands.
We can also run
update resourcecount domainid=<ID>to update the resource before running the above command.