You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "stephankruggg (via GitHub)" <gi...@apache.org> on 2023/02/13 19:24:26 UTC

[GitHub] [cloudstack] stephankruggg opened a new pull request, #7210: Set number of hours per month with actual number in Quota

stephankruggg opened a new pull request, #7210:
URL: https://github.com/apache/cloudstack/pull/7210

   ### Description
   
   The Quota usage value for monthly usage types uses the cost per hour to calculate the total tariff value in a particular period. In order to define the cost per hour, it takes into account the total number of hours in each month. However, this value is currently fixed at 720 hours for every month. 
   
   This causes incorrect values when calculating the cost per hour, resulting in costs being higher than expected. Therefore, this PR aims to calculate the number of hours in each month based on the actual number of days of each month.
   
   For example, if the tariff value is 100 per month, the current cost per hour is 0.138888889 for every month. For 1 hour per month the total cost in a year would be 1.666666668.
   With the adjustments to the cost per hour of this PR, the costs per hour would be: 0.134408602 (January, March, May, July, August, October, December), 0.148809524 (February of a non-leap year), 0.143678161 (February of a leap year), and 0.138888889 (April, June, September, November). This results in 1.645225294 for a non-leap year and 1.640093931 for a leap year at 1 hour per month, which is a difference of about 1.3% in costs to the current method.
   
   ### 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)
   - [X] 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
   - [X] Minor
   
   ### How Has This Been Tested?
   
   In a local lab I applied the changes, and manually changed the current month of the MS to every month in a year (including February of a leap year) and verified if the cost per hour was calculated correctly using the number of hours of each month when the `quotaUpdate` API was called. 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1813955152

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1812682795

   @DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1812793988

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 7763


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1812683323

   ui build error is in codecov push, not in code.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1812681434

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1744624604

   @stephankruggg cc @GaOrtiga can you please check the outstanding review comments?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1813954535

   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "GaOrtiga (via GitHub)" <gi...@apache.org>.
GaOrtiga commented on code in PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#discussion_r1381821484


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java:
##########
@@ -558,6 +563,14 @@ protected BigDecimal getUsageValueAccordingToUsageUnitType(UsageVO usageRecord,
         }
     }
 
+    protected void setHoursInCurrentMonth() {
+        LocalDate currentDate = LocalDate.now();

Review Comment:
   @DaanHoogland, sorry for the delay. 
   I have implemented some changes to address the issues you pointed out by getting the date directly from each record.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] sonarcloud[bot] commented on pull request #7210: Set number of hours per month with actual number in Quota

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1428636477

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache_cloudstack&pullRequest=7210)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=7210&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=7210&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=7210&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=7210&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=7210&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=7210&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=7210&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=7210&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=7210&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=7210&resolved=false&types=CODE_SMELL) [![B](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/B-16px.png 'B')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=7210&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=7210&resolved=false&types=CODE_SMELL)
   
   [![11.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '11.1%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=7210&metric=new_coverage&view=list) [11.1% Coverage](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=7210&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=7210&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=7210&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland merged PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1815308955

   <b>[SF] Trillian test result (tid-8331)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 45428 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7210-t8331-kvm-centos7.zip
   Smoke tests completed. 117 look OK, 1 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_08_migrate_vm | `Error` | 0.06 | test_vm_life_cycle.py
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set number of hours per month with actual number in Quota [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1787329853

   @stephankruggg can you answer my question https://github.com/apache/cloudstack/pull/7210#discussion_r1105876041 ?
   Any daylight saving or leap year/ - second issues possible there?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] codecov[bot] commented on pull request #7210: Set number of hours per month with actual number in Quota

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#issuecomment-1428631364

   # [Codecov](https://codecov.io/gh/apache/cloudstack/pull/7210?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7210](https://codecov.io/gh/apache/cloudstack/pull/7210?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b62e20e) into [main](https://codecov.io/gh/apache/cloudstack/commit/933970d9da0791ae0867ed9c3d2b318b4029660a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (933970d) will **decrease** coverage by `0.01%`.
   > The diff coverage is `12.50%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #7210      +/-   ##
   ============================================
   - Coverage     12.67%   12.67%   -0.01%     
   + Complexity     8642     8639       -3     
   ============================================
     Files          2716     2716              
     Lines        256112   256118       +6     
     Branches      39926    39926              
   ============================================
   - Hits          32462    32455       -7     
   - Misses       219520   219535      +15     
   + Partials       4130     4128       -2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/cloudstack/pull/7210?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../org/apache/cloudstack/quota/QuotaManagerImpl.java](https://codecov.io/gh/apache/cloudstack/pull/7210?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZnJhbWV3b3JrL3F1b3RhL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9jbG91ZHN0YWNrL3F1b3RhL1F1b3RhTWFuYWdlckltcGwuamF2YQ==) | `43.79% <12.50%> (-1.44%)` | :arrow_down: |
   | [...com/cloud/agent/manager/ConnectedAgentAttache.java](https://codecov.io/gh/apache/cloudstack/pull/7210?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL29yY2hlc3RyYXRpb24vc3JjL21haW4vamF2YS9jb20vY2xvdWQvYWdlbnQvbWFuYWdlci9Db25uZWN0ZWRBZ2VudEF0dGFjaGUuamF2YQ==) | `25.00% <0.00%> (-12.50%)` | :arrow_down: |
   | [...va/com/cloud/agent/manager/DirectAgentAttache.java](https://codecov.io/gh/apache/cloudstack/pull/7210?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL29yY2hlc3RyYXRpb24vc3JjL21haW4vamF2YS9jb20vY2xvdWQvYWdlbnQvbWFuYWdlci9EaXJlY3RBZ2VudEF0dGFjaGUuamF2YQ==) | `9.83% <0.00%> (-0.55%)` | :arrow_down: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #7210: Set number of hours per month with actual number in Quota

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #7210:
URL: https://github.com/apache/cloudstack/pull/7210#discussion_r1105876041


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java:
##########
@@ -558,6 +563,14 @@ protected BigDecimal getUsageValueAccordingToUsageUnitType(UsageVO usageRecord,
         }
     }
 
+    protected void setHoursInCurrentMonth() {
+        LocalDate currentDate = LocalDate.now();

Review Comment:
   @stephankruggg is it possible that this calculation happens for just a minute ago/last month on the 1st of the next month. How will this be handled?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org