You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "shwstppr (via GitHub)" <gi...@apache.org> on 2025/07/28 05:25:00 UTC

[PR] server: fix NaN metrics for external resources [cloudstack]

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

   ### Description
   
   This PR...
   <!--- Describe your changes in DETAIL - And how has behaviour functionally changed. -->
   
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   <!-- Fixes: # -->
   
   <!--- ******************************************************************************* -->
   <!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
   <!--- PLEASE PUT AN 'X' in only **ONE** box -->
   <!--- ******************************************************************************* -->
   
   ### 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)
   - [ ] build/CI
   - [ ] test (unit or integration test code)
   
   ### 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?
   
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to -->
   
   #### How did you try to break this feature and the system with this change?
   
   <!-- see how your change affects other areas of the code, etc. -->
   
   <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
   


-- 
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] server: fix NaN metrics for external resources [cloudstack]

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


##########
server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java:
##########
@@ -401,6 +400,9 @@ public List<HostJoinVO> findByClusterId(Long clusterId, Host.Type type) {
     }
 
     private String calculateResourceAllocatedPercentage(float resource, float resourceWithOverProvision) {
+        if (resource == 0 || resourceWithOverProvision == 0) {
+            return "0.00%";
+        }
         DecimalFormat decimalFormat = new DecimalFormat("#.##");
         return decimalFormat.format(((float)resource / resourceWithOverProvision * 100.0f)) + "%";

Review Comment:
   The cast to (float) is unnecessary since the parameters are already declared as float. This redundant cast reduces code readability.
   ```suggestion
           return decimalFormat.format((resource / resourceWithOverProvision * 100.0f)) + "%";
   ```



##########
server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java:
##########
@@ -401,6 +400,9 @@ public List<HostJoinVO> findByClusterId(Long clusterId, Host.Type type) {
     }
 
     private String calculateResourceAllocatedPercentage(float resource, float resourceWithOverProvision) {
+        if (resource == 0 || resourceWithOverProvision == 0) {

Review Comment:
   The condition should check for resourceWithOverProvision == 0 only, since dividing by zero resource value is valid and would result in 0%. The current logic incorrectly returns 0% when resource is 0 but resourceWithOverProvision is non-zero, which should actually calculate as 0% anyway but through the normal formula.
   ```suggestion
           if (resourceWithOverProvision == 0) {
   ```



-- 
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] server: fix NaN metrics for external resources [cloudstack]

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

   @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] server: fix NaN metrics for external resources [cloudstack]

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


##########
server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java:
##########
@@ -401,6 +400,9 @@ public List<HostJoinVO> findByClusterId(Long clusterId, Host.Type type) {
     }
 
     private String calculateResourceAllocatedPercentage(float resource, float resourceWithOverProvision) {
+        if (resource == 0 || resourceWithOverProvision == 0) {

Review Comment:
   I don't agree. When we know value is zero why do the calculation unnecessarily.



-- 
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] server: fix NaN metrics for external resources [cloudstack]

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

   ## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/11302?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 3.82%. Comparing base ([`cca8b2f`](https://app.codecov.io/gh/apache/cloudstack/commit/cca8b2fef9016bc04cde10f2f2ef4bf6f345155e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`913655f`](https://app.codecov.io/gh/apache/cloudstack/commit/913655fcc7a796bfebf2a5b7553664fd5bca9cd8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@          Coverage Diff           @@
   ##            main   #11302   +/-   ##
   ======================================
     Coverage   3.82%    3.82%           
   ======================================
     Files        432      432           
     Lines      34897    34897           
     Branches    6294     6294           
   ======================================
     Hits        1334     1334           
     Misses     33403    33403           
     Partials     160      160           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/11302/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/11302/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `3.82% <ø> (ø)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/11302?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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] server: fix NaN metrics for external resources [cloudstack]

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


-- 
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] server: fix NaN metrics for external resources [cloudstack]

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

   Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14408


-- 
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] server: fix NaN metrics for external resources [cloudstack]

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

   @sureshanaparti I don't think Copilot's comment are completely relevant. I've added my comments in their reply


-- 
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] server: fix NaN metrics for external resources [cloudstack]

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

   @sureshanaparti 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] server: fix NaN metrics for external resources [cloudstack]

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


##########
server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java:
##########
@@ -401,6 +400,9 @@ public List<HostJoinVO> findByClusterId(Long clusterId, Host.Type type) {
     }
 
     private String calculateResourceAllocatedPercentage(float resource, float resourceWithOverProvision) {
+        if (resource == 0 || resourceWithOverProvision == 0) {
+            return "0.00%";
+        }
         DecimalFormat decimalFormat = new DecimalFormat("#.##");
         return decimalFormat.format(((float)resource / resourceWithOverProvision * 100.0f)) + "%";

Review Comment:
   Can be a separate PR/change as not touched here



-- 
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] server: fix NaN metrics for external resources [cloudstack]

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

   @blueoranutan 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] server: fix NaN metrics for external resources [cloudstack]

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

   > I think both copilot’s remarks make sense. otherwise clgtm
   
   @shwstppr can check if copilot's commits are relevant?


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