Skip to content

Commit 8fcffc9

Browse files
committed
Only request metric collections for hosts connected to the MS
1 parent c8b7816 commit 8fcffc9

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

server/src/main/java/com/cloud/server/StatsCollector.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,14 @@ protected void runInContext() {
12261226

12271227
Map<Object, Object> metrics = new HashMap<>();
12281228
for (HostVO host : hosts) {
1229+
if (host.getHypervisorType() == HypervisorType.KVM && ManagementServerNode.getManagementServerId() != host.getManagementServerId()) {
1230+
// 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,
1231+
// 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.
1232+
// Furthermore, the number of stat entries on the DB scales with the number of Management Servers. Therefore, we only request the stat collections from
1233+
// hosts connected to the Management Server, honoring the interval, presenting the correct data, and reducing the necessary storage to store the VMs stats.
1234+
logger.debug("Skipping VM stat collection for [{}] as it is connected to another Management Server node [{}].", host, host.getManagementServerId());
1235+
continue;
1236+
}
12291237
Date timestamp = new Date();
12301238
Pair<Map<Long, VMInstanceVO>, Map<String, Long>> vmsAndMap = getVmMapForStatsForHost(host);
12311239
Map<Long, VMInstanceVO> vmMap = vmsAndMap.first();

0 commit comments

Comments
 (0)