You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "MitchDrage (via GitHub)" <gi...@apache.org> on 2026/10/13 22:06:21 UTC

[PR] Collect VM stats only from hosts connected to this management server [cloudstack]

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

   ### Description
   
   Fixes #14397
   
   This PR makes each management server collect VM stats only from the hosts connected to it. Previously every management server polled every host, so with 3 management servers each VM got 3 rows in `vm_stats` per interval.
   
   - `VmStatsCollector` now filters its host search on `managementServerId`.
   - `HostCollector` is unchanged and still collects from all hosts.
   - Added unit tests for both collectors' host searches.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [x] 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
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [x] Minor
   - [ ] Trivial
   
   ### Screenshots (if appropriate):
   
   ### How Has This Been Tested?
   
   - `StatsCollectorTest` passes (60 tests), including the two new ones.
   - With the fix removed, the new `VmStatsCollector` test fails.
   
   #### How did you try to break this feature and the system with this change?
   
   - Checked that nothing reads `vm_stats.mgmt_server_id`. The UI charts, `listVirtualMachines` and the cleanup job all query by VM ID and timestamp and select the newest returned row, so they still see every VM's stats.
   - If a host reconnects to a different management server, at most one or two samples are missed.
   


-- 
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] Collect VM stats only from hosts connected to this management server [cloudstack]

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

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


-- 
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] Collect VM stats only from hosts connected to this management server [cloudstack]

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

   <b>[SF] Trillian test result (tid-17191)</b>
   Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
   Total time taken: 61324 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14398-t17191-kvm-ol8.zip
   Smoke tests completed. 140 look OK, 1 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_03_ssvm_internals | `Failure` | 3.21 | test_ssvm.py
   test_05_stop_ssvm | `Failure` | 76.42 | test_ssvm.py
   test_07_reboot_ssvm | `Failure` | 137.20 | test_ssvm.py
   test_09_reboot_ssvm_forced | `Failure` | 154.19 | test_ssvm.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] Collect VM stats only from hosts connected to this management server [cloudstack]

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


##########
server/src/main/java/com/cloud/server/StatsCollector.java:
##########
@@ -1220,6 +1220,7 @@ class VmStatsCollector extends AbstractStatsCollector {
         protected void runInContext() {
             try {
                 SearchCriteria<HostVO> sc = createSearchCriteriaForHostTypeRoutingStateUpAndNotInMaintenance();
+                sc.addAnd("managementServerId", SearchCriteria.Op.EQ, managementServerNodeId);

Review Comment:
   Done. I also raised another issue for the Xen and VMware problem so that it's tracked properly.



-- 
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] Collect VM stats only from hosts connected to this management server [cloudstack]

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

   @blueorangutan test keepEnv


-- 
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] Collect VM stats only from hosts connected to this management server [cloudstack]

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

   @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] Collect VM stats only from hosts connected to this management server [cloudstack]

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

   <b>[SF] Trillian test result (tid-17211)</b>
   Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
   Total time taken: 62920 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14398-t17211-kvm-ol8.zip
   Smoke tests completed. 141 look OK, 0 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
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] Collect VM stats only from hosts connected to this management server [cloudstack]

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

   ## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/14398?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 4.16%. Comparing base ([`376c1b4`](https://app.codecov.io/gh/apache/cloudstack/commit/376c1b40174ab4b8d7f9aced5401143cbc09d587?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`556df61`](https://app.codecov.io/gh/apache/cloudstack/commit/556df61680a097c34569c3599ef072b3ebe533af?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   > :exclamation:  There is a different number of reports uploaded between BASE (376c1b4) and HEAD (556df61). Click for more details.
   > 
   > <details><summary>HEAD has 1 upload less than BASE</summary>
   >
   >| Flag | BASE (376c1b4) | HEAD (556df61) |
   >|------|------|------|
   >|unittests|1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##               4.20   #14398       +/-   ##
   =============================================
   - Coverage     16.41%    4.16%   -12.25%     
   =============================================
     Files          5669      405     -5264     
     Lines        501628    33078   -468550     
     Branches      60942     5903    -55039     
   =============================================
   - Hits          82336     1378    -80958     
   + Misses       410064    31524   -378540     
   + Partials       9228      176     -9052     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/14398/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/14398/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.16% <ø> (ø)` | |
   | [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/14398/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   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 Harness](https://app.codecov.io/gh/apache/cloudstack/pull/14398?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] Collect VM stats only from hosts connected to this management server [cloudstack]

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

   @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] Collect VM stats only from hosts connected to this management server [cloudstack]

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


##########
server/src/main/java/com/cloud/server/StatsCollector.java:
##########
@@ -1220,6 +1220,7 @@ class VmStatsCollector extends AbstractStatsCollector {
         protected void runInContext() {
             try {
                 SearchCriteria<HostVO> sc = createSearchCriteriaForHostTypeRoutingStateUpAndNotInMaintenance();
+                sc.addAnd("managementServerId", SearchCriteria.Op.EQ, managementServerNodeId);

Review Comment:
   that covers it. can we add a line to the description that vmware and xen totals will drop to the real value after upgrade? anyone watching those numbers will see the change



-- 
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] Collect VM stats only from hosts connected to this management server [cloudstack]

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

   @DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) 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] Collect VM stats only from hosts connected to this management server [cloudstack]

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


##########
server/src/main/java/com/cloud/server/StatsCollector.java:
##########
@@ -1220,6 +1220,7 @@ class VmStatsCollector extends AbstractStatsCollector {
         protected void runInContext() {
             try {
                 SearchCriteria<HostVO> sc = createSearchCriteriaForHostTypeRoutingStateUpAndNotInMaintenance();
+                sc.addAnd("managementServerId", SearchCriteria.Op.EQ, managementServerNodeId);

Review Comment:
   does this change the totals for anyone with vm.stats.increment.metrics on? those add up every saved row, so network and disk totals were counted once per management server until now and will drop after upgrade



-- 
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] Collect VM stats only from hosts connected to this management server [cloudstack]

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


##########
server/src/main/java/com/cloud/server/StatsCollector.java:
##########
@@ -1220,6 +1220,7 @@ class VmStatsCollector extends AbstractStatsCollector {
         protected void runInContext() {
             try {
                 SearchCriteria<HostVO> sc = createSearchCriteriaForHostTypeRoutingStateUpAndNotInMaintenance();
+                sc.addAnd("managementServerId", SearchCriteria.Op.EQ, managementServerNodeId);

Review Comment:
   Thanks for raising this.
   The result for KVM is that the value returned by LibvirtComputingResource.getVmStat is a delta since the last poll by any management server, so the total will be the same, just counted less often.
   
   I'm only familiar with KVM so I went looking into your question a bit further to be sure.
   For VMware and Xen it's a bit more interesting... From the best I can see (and I got some AI help to confirm), each poll there returns an average over a fixed window, so every management server stores roughly the same value. With vm.stats.increment.metrics on, those rows get added up, so the totals have been N times the real value (where N is the number of management servers). My fix inadvertently solves a bug I didn't see.
   For example, a VMware VM receiving a steady 100 KB/s with 3 management servers stores three rows of ~100 every minute which get added up, so the total goes up by 300 each minute. With one management server, or with this fix, it goes up by 100.



-- 
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] Collect VM stats only from hosts connected to this management server [cloudstack]

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

   it looks good but I will do a quick manual verification once smoke tests pass.


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