Skip to content

Fix #3448 quota calculation for monthly tariffs - #5517

Merged
DaanHoogland merged 2 commits into
apache:4.16from
jairov4:bugfix/bug-gh-3448-wrong-quota-calculation
Feb 7, 2022
Merged

Fix #3448 quota calculation for monthly tariffs#5517
DaanHoogland merged 2 commits into
apache:4.16from
jairov4:bugfix/bug-gh-3448-wrong-quota-calculation

Conversation

@jairov4

@jairov4 jairov4 commented Sep 28, 2021

Copy link
Copy Markdown
Contributor

Description

The quota calculation has been wrong for monthly tariffs (like Compute-Month, GB-Month, etc) for so much time but even when #3448 was reported it was closed without evaluation.

The wrong calculation was the price per hour, it was taking the monthly tariff and multiplying by the aggregation ratio which has no sense at all.

The right price per hour is the monthly tariff divided by the standard number of hours in a month.

Fixes #3448.

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

How Has This Been Tested?

Partial execution of the component with a test vector.
Tracing the values and compared with spreadsheet.

@DaanHoogland

Copy link
Copy Markdown
Contributor

Your code looks alright @jairov4 but only if the aggregation is always hourly. I think there is another problem with the code and that is that the onehour vars are not named correctly; BigDecimal onehourcostpercpu, onehourcostper100mhz, onehourcostper1mb, onehourcostforvmusage;. I think these should have been called 'oneaggregation*'.
Have you tested with other agrregation durations?
Care to comment @abhinandanprateek , @rhtyd , @rafaelweingartner ? (not sure who else to ask)

@jairov4

jairov4 commented Sep 28, 2021

Copy link
Copy Markdown
Contributor Author

@DaanHoogland yes, this calculation is independent of the aggregation ratio because the raw usage variable is the number of hours used, then we only need the hour cost to compute the final quota for the aggregation time slot. As you can see in src/main/java/com/cloud/usage/parser/VMInstanceUsageParser.java
image

@jairov4

jairov4 commented Oct 1, 2021

Copy link
Copy Markdown
Contributor Author

btw: should I rebase it to 4.15?

@DaanHoogland

Copy link
Copy Markdown
Contributor

You can rebase it @jairov4 , if you want it on that branch. It is unlikely an new 4.15 version will come out. if you do it will be merged forward to 4.16 as well.

@yadvr
yadvr changed the base branch from main to 4.16 November 15, 2021 10:10
@yadvr yadvr added this to the 4.16.1.0 milestone Nov 15, 2021
@yadvr

yadvr commented Nov 18, 2021

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✖️ el8 ✖️ debian ✖️ suse15. SL-JID 1729

@yadvr

yadvr commented Jan 8, 2022

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 2144

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti 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-2838)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 31162 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5517-t2838-kvm-centos7.zip
Smoke tests completed. 92 look OK, 0 have errors
Only failed tests results shown below:

Test Result Time (s) Test File

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

genrally good to go, but some instances of the parameter aggregationRotio need to be removed.

@DaanHoogland
DaanHoogland changed the base branch from 4.16 to 4.15 January 11, 2022 14:59
@DaanHoogland
DaanHoogland changed the base branch from 4.15 to 4.16 January 11, 2022 15:00

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

@jairov4 , please remove the parameter aggregationRatio from methods that no longer use it.

@sureshanaparti sureshanaparti self-assigned this Jan 28, 2022
@sureshanaparti

Copy link
Copy Markdown
Contributor

@jairov4 , please remove the parameter aggregationRatio from methods that no longer use it.

Hi @jairov4 Can you address the outstanding comments please. Thanks.

@jairov4

jairov4 commented Feb 4, 2022

Copy link
Copy Markdown
Contributor Author

@sureshanaparti done!

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 2461

@apache apache deleted a comment from blueorangutan Feb 4, 2022
@apache apache deleted a comment from blueorangutan Feb 4, 2022
@DaanHoogland

Copy link
Copy Markdown
Contributor

@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-3164)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 32912 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5517-t3164-kvm-centos7.zip
Smoke tests completed. 92 look OK, 0 have errors
Only failed tests results shown below:

Test Result Time (s) Test File

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

cltgm

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

code LGTM

@DaanHoogland

Copy link
Copy Markdown
Contributor

@jairov4 looks good no regressions. The test_quota.py integration test is not run in either the smoke tests or in travis, So I'll run thos manually to make triple sure.

@DaanHoogland

Copy link
Copy Markdown
Contributor

I ran the quota tests and got all to succeed except for one that requires more than a single day of data to accumulate. recarding this as success and merging because of succesfull testing and multiple LTGM.

@DaanHoogland
DaanHoogland merged commit 6c9f0c1 into apache:4.16 Feb 7, 2022
@DaanHoogland DaanHoogland mentioned this pull request Feb 7, 2022
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Quota calculation is incorrect

6 participants