Skip to content

Quota VM_DISK tariff calculation - #7152

Merged
DaanHoogland merged 3 commits into
apache:mainfrom
scclouds:quota-vm-disk-calculation
Feb 3, 2023
Merged

DaanHoogland merged 3 commits into
apache:mainfrom
scclouds:quota-vm-disk-calculation

Conversation

@BryanMLima

Copy link
Copy Markdown
Contributor

Description

Currently, the quota plugin ignores the tariff calculation for the types below:

  • VM_DISK_IO_READ
  • VM_DISK_IO_WRITE
  • VM_DISK_BYTES_READ
  • VM_DISK_BYTES_WRITE

The code was changed as to now calculate the quota tariff for these types. Moreover, the unit types were changed as well, as shown in the table below. It is noteworthy that the raw values for these types are not modified; therefore, the calculation of the tariff for them are: TARIFF * CONSUMPTION.

Type Unit
VM_DISK_IO_READ IOPS
VM_DISK_IO_WRITE IOPS
VM_DISK_BYTES_READ Bytes
VM_DISK_BYTES_WRITE Bytes

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)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

This was tested in a local lab creating a quota tariff for each type. Then, I reinstalled a previously created VM and generated a quota statement.

Creating a quota tariff with type VM_DISK_IO_READ:

(lab-bryan) 🐱 > quota tariffcreate name=mr-443-21 usagetype=21 value=30
{
  "quotatariff": {
    "currency": "$",
    "effectiveDate": "2023-01-24T15:39:39+0000",
    "name": "mr-443-21",
    "tariffValue": 30,
    "usageDiscriminator": "None",
    "usageName": "VM_DISK_IO_READ",
    "usageType": 21,
    "usageTypeDescription": "VM Disk usage(I/O Read)",
    "usageUnit": "IOPS",
    "uuid": "e580d696-5e5e-4423-87e5-130298a2cb0f"
  }
}
(lab) 🐱 > quota statement accountid=af16aaed-26de-11ec-8dcf-5254005dcdac account=admin domainid=52d83793-26de-11ec-8dcf-5254005dcdac startdate=2023-01-23 enddate=2023-01-25
{
  "statement": {
    "currency": "$",
    "enddate": "2023-01-25T23:59:59+0000",
    "quotausage": [
      (...)
      {
        "accountid": "af16aaed-26de-11ec-8dcf-5254005dcdac",
        "domain": "52d83793-26de-11ec-8dcf-5254005dcdac",
        "name": "VM_DISK_IO_READ",
        "quota": 771439.82,
        "type": 21,
        "unit": "IOPS"
      },
      {
        "accountid": "af16aaed-26de-11ec-8dcf-5254005dcdac",
        "domain": "52d83793-26de-11ec-8dcf-5254005dcdac",
        "name": "VM_DISK_IO_WRITE",
        "quota": 0.44,
        "type": 22,
        "unit": "IOPS"
      },
      {
        "accountid": "af16aaed-26de-11ec-8dcf-5254005dcdac",
        "domain": "52d83793-26de-11ec-8dcf-5254005dcdac",
        "name": "VM_DISK_BYTES_READ",
        "quota": 12667348.48,
        "type": 23,
        "unit": "Bytes"
      },
      {
        "accountid": "af16aaed-26de-11ec-8dcf-5254005dcdac",
        "domain": "52d83793-26de-11ec-8dcf-5254005dcdac",
        "name": "VM_DISK_BYTES_WRITE",
        "quota": 2929711.64,
        "type": 24,
        "unit": "Bytes"
      }
      (...)
    ],
    "startdate": "2023-01-23T00:00:00+0000",
    "totalquota": 16368503.29
  }
}

@BryanMLima BryanMLima changed the title Quota vm disk calculation Quota VM_DISK tariff calculation Jan 31, 2023
@codecov

codecov Bot commented Jan 31, 2023 •

Copy link
Copy Markdown

Codecov Report

Merging #7152 (e0c6f71) into main (83c2bfa) will increase coverage by 0.83%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main    #7152      +/-   ##
============================================
+ Coverage     11.79%   12.63%   +0.83%     
- Complexity     7692     8610     +918     
============================================
  Files          2511     2711     +200     
  Lines        246578   255748    +9170     
  Branches      38446    39871    +1425     
============================================
+ Hits          29090    32312    +3222     
- Misses       213703   219337    +5634     
- Partials       3785     4099     +314     
Impacted Files Coverage Δ
.../org/apache/cloudstack/quota/QuotaManagerImpl.java 45.23% <100.00%> (+0.31%) ⬆️
...g/apache/cloudstack/quota/constant/QuotaTypes.java 100.00% <100.00%> (ø)
...dstack/network/contrail/model/ModelObjectBase.java 28.84% <0.00%> (-19.24%) ⬇️
...cloudstack/network/contrail/model/ModelObject.java 29.16% <0.00%> (-4.17%) ⬇️
.../src/main/java/com/cloud/configuration/Config.java 88.91% <0.00%> (-0.82%) ⬇️
...ervisor/kvm/resource/LibvirtComputingResource.java 18.31% <0.00%> (-0.34%) ⬇️
...udstack/consoleproxy/ConsoleAccessManagerImpl.java 4.90% <0.00%> (-0.32%) ⬇️
.../com/cloud/api/query/vo/NetworkOfferingJoinVO.java 24.39% <0.00%> (-0.31%) ⬇️
...java/com/cloud/server/ConfigurationServerImpl.java 2.29% <0.00%> (-0.07%) ⬇️
...in/java/com/cloud/server/ManagementServerImpl.java 5.66% <0.00%> (-0.06%) ⬇️
... and 248 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm,
Is there any compelling reason to have this included in 4.18, @BryanMLima @GutoVeronezi , as the custom quota tarrifs is also part of 4.18?

@GutoVeronezi

Copy link
Copy Markdown
Contributor

clgtm, Is there any compelling reason to have this included in 4.18, @BryanMLima @GutoVeronezi , as the custom quota tarrifs is also part of 4.18?

@DaanHoogland, previously to introducing the custom quota tariffs, those usage types already were not calculated:

It would be good to have this in 4.18; however, I do not see it as mandatory. In the worst case, nothing changes to the final user.

@yadvr yadvr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Didn't test it but changes LGTM.

@GutoVeronezi GutoVeronezi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CLGTM

@BryanMLima, I pointed out a minor adjust in the comment in SQL.

@stephankruggg stephankruggg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CLGTM

@DaanHoogland

Copy link
Copy Markdown
Contributor

@GutoVeronezi cc @BryanMLima , I am happy to include this in 4.18, especially as the unit test is adjusted to include this and the risk for other features is minimal. Is there any more automated testing that could be added for this?

Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
@BryanMLima

Copy link
Copy Markdown
Contributor Author

@DaanHoogland cc @GutoVeronezi Thanks for adding to version 4.18. Regarding the automated testing, I don't think so, as it is a rather simple addition.

@sonarqubecloud

sonarqubecloud Bot commented Feb 2, 2023

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

92.9% 92.9% Coverage
0.0% 0.0% Duplication

@DaanHoogland DaanHoogland added this to the 4.18.0.0 milestone Feb 3, 2023
@DaanHoogland
DaanHoogland merged commit 5c20e78 into apache:main Feb 3, 2023
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.

5 participants