From 8fcffc98aa7f758cf0d79c2eb884f15d1f6a10ef Mon Sep 17 00:00:00 2001 From: Ortiga Date: Tue, 7 Jul 2026 10:48:12 -0300 Subject: [PATCH 1/2] Only request metric collections for hosts connected to the MS --- server/src/main/java/com/cloud/server/StatsCollector.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/src/main/java/com/cloud/server/StatsCollector.java b/server/src/main/java/com/cloud/server/StatsCollector.java index 1e0138f7cf90..705c3cff14a8 100644 --- a/server/src/main/java/com/cloud/server/StatsCollector.java +++ b/server/src/main/java/com/cloud/server/StatsCollector.java @@ -1226,6 +1226,14 @@ protected void runInContext() { Map metrics = new HashMap<>(); for (HostVO host : hosts) { + if (host.getHypervisorType() == HypervisorType.KVM && ManagementServerNode.getManagementServerId() != host.getManagementServerId()) { + // When there are multiple Management Server nodes on the environment, all of them request stat collections for the same VM in different moments; with that, + // the interval from "vm.stats.interval" is not respected. Also, the stats commands are routed to the Management Server connected to the Agent where the VM is running. + // Furthermore, the number of stat entries on the DB scales with the number of Management Servers. Therefore, we only request the stat collections from + // hosts connected to the Management Server, honoring the interval, presenting the correct data, and reducing the necessary storage to store the VMs stats. + logger.debug("Skipping VM stat collection for [{}] as it is connected to another Management Server node [{}].", host, host.getManagementServerId()); + continue; + } Date timestamp = new Date(); Pair, Map> vmsAndMap = getVmMapForStatsForHost(host); Map vmMap = vmsAndMap.first(); From 938dd5e78f05f1abc5ff4860c189135b2c08f495 Mon Sep 17 00:00:00 2001 From: GaOrtiga <49285692+GaOrtiga@users.noreply.github.com> Date: Mon, 13 Jul 2026 15:45:58 -0300 Subject: [PATCH 2/2] Update server/src/main/java/com/cloud/server/StatsCollector.java Co-authored-by: Fabricio Duarte --- server/src/main/java/com/cloud/server/StatsCollector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/server/StatsCollector.java b/server/src/main/java/com/cloud/server/StatsCollector.java index 705c3cff14a8..d626282dc9c3 100644 --- a/server/src/main/java/com/cloud/server/StatsCollector.java +++ b/server/src/main/java/com/cloud/server/StatsCollector.java @@ -1226,7 +1226,7 @@ protected void runInContext() { Map metrics = new HashMap<>(); for (HostVO host : hosts) { - if (host.getHypervisorType() == HypervisorType.KVM && ManagementServerNode.getManagementServerId() != host.getManagementServerId()) { + if (HypervisorType.KVM.equals(host.getHypervisorType()) && ManagementServerNode.getManagementServerId() != host.getManagementServerId()) { // When there are multiple Management Server nodes on the environment, all of them request stat collections for the same VM in different moments; with that, // the interval from "vm.stats.interval" is not respected. Also, the stats commands are routed to the Management Server connected to the Agent where the VM is running. // Furthermore, the number of stat entries on the DB scales with the number of Management Servers. Therefore, we only request the stat collections from