Skip to content

server: Fix resource count of primary storage/volume because of Expunged volumes#3669

Merged
DaanHoogland merged 1 commit into
apache:masterfrom
ravening:volume-resource-count
Nov 29, 2019
Merged

server: Fix resource count of primary storage/volume because of Expunged volumes#3669
DaanHoogland merged 1 commit into
apache:masterfrom
ravening:volume-resource-count

Conversation

@ravening
Copy link
Copy Markdown
Member

@ravening ravening commented Nov 7, 2019

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

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Screenshots (if appropriate):

How Has This Been Tested?

This has been tested using the cloudmonkey api commands.

list domains id=<ID> filter=primarystorageavailable,primarystoragelimit,primarystoragetotal

We can also run update resourcecount domainid=<ID> to update the resource before running the above command.

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 weizhouapache self-requested a review November 12, 2019 14:12
@weizhouapache weizhouapache changed the title Fix resource count of expunged volume server: Fix resource count of primary storage/volume because of Expunged volumes Nov 12, 2019
Copy link
Copy Markdown
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@weizhouapache
Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@weizhouapache
Copy link
Copy Markdown
Member

@blueorangutan help

@blueorangutan
Copy link
Copy Markdown

@weizhouapache I understand these words: "help", "hello", "thanks", "package", "test"
Test command usage: test [mgmt os] [hypervisor] [additional tests]
Mgmt OS options: ['centos6', 'centos7', 'ubuntu']
Hypervisor options: ['kvm-centos6', 'kvm-centos7', 'kvm-ubuntu', 'xenserver-71', 'xenserver-65sp1', 'xenserver-62sp1', 'vmware-65u2', 'vmware-60u2', 'vmware-55u3', 'vmware-51u1', 'vmware-50u1']
Additional tests: list of space separated tests with paths relative to the test/integration directory, for example: component/test_acl_listvm.py component/test_volumes.py
Note: when additional tests are passed, you need to specify mgmt server os and hypervisor or use the matrix command.

Blessed contributors for kicking Trillian test jobs: ['rhtyd', 'nvazquez', 'PaulAngus', 'borisstoyanov', 'DaanHoogland', 'anuragaw', 'shwstppr', 'andrijapanicsb', 'Spaceman1984']

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✖centos6 ✔centos7 ✔debian. JID-351

@DaanHoogland
Copy link
Copy Markdown
Contributor

@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.

Copy link
Copy Markdown
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code LGTM

@weizhouapache
Copy link
Copy Markdown
Member

@rhtyd @DaanHoogland @andrijapanicsb can you kick off a test ?

by the way, is it possible to grant me access to kick a test ?

@DaanHoogland
Copy link
Copy Markdown
Contributor

@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.
@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-502)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 27677 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr3669-t502-kvm-centos7.zip
Smoke tests completed. 77 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

@weizhouapache
Copy link
Copy Markdown
Member

The PR has two approvals , and BO tests passed.
is it ready for merge ?

@DaanHoogland
Copy link
Copy Markdown
Contributor

@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.

@DaanHoogland DaanHoogland merged commit f30b5ce into apache:master Nov 29, 2019
@yadvr yadvr added this to the 4.14.0.0 milestone Nov 30, 2019
ustcweizhou pushed a commit to ustcweizhou/cloudstack that referenced this pull request Feb 28, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants