Copilot commented on code in PR #13218:
URL: https://github.com/apache/cloudstack/pull/13218#discussion_r4445116390
##########
plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterImpl.java:
##########
@@ -501,10 +512,47 @@ private void addVMsBySizeMetrics(final List<Item>
metricsList, final long dcId,
}
}
+ protected void addVirtualRouterHealthCheckMetrics(final List<Item>
metricsList, final long dcId, final String zoneName, final String zoneUuid) {
+ List<DomainRouterVO> routers = domainRouterDao.listByDataCenter(dcId);
+ if (routers == null) {
+ return;
+ }
+ // only running virtual routers; results of stopped or destroyed
routers are stale
+ Map<Long, DomainRouterVO> runningRouters = routers.stream()
+ .filter(router -> router.getRole() ==
VirtualRouter.Role.VIRTUAL_ROUTER && router.getState() == State.Running)
+ .collect(Collectors.toMap(DomainRouterVO::getId, router ->
router));
Review Comment:
`listByDataCenter()` joins router network references without deduplication,
so a running VPC router attached to multiple networks produces duplicate IDs
and makes this collector throw `IllegalStateException`. This aborts the
remaining metrics collection, skipping health checks for this zone, subsequent
zones, and domain-limit/resource-count metrics. Add a merge function to
deduplicate routers by ID, and cover repeated router IDs in a regression test.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]