From 8fcffc98aa7f758cf0d79c2eb884f15d1f6a10ef Mon Sep 17 00:00:00 2001 From: Ortiga Date: Tue, 7 Jul 2026 10:48:12 -0300 Subject: [PATCH] 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();