Skip to content

Commit 7e30e3d

Browse files
authored
router: Avoid duplicate alerts when router state changes (#3904)
When both routers of VPC is in MASTER state then multiple alerts are sent equally to the number of tiers in the VPC. If the VPC has 3 tiers then 6 alerts will be sent. This is not good if VPC has more than 10 networks in it. Instead of checking the router status for all the tiers in the VPC, just check the status of the router for one tier in a VPC so that multiple duplicate alerts can be avoided
1 parent abb39a2 commit 7e30e3d

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,9 @@ private void checkDuplicateMaster(final List<DomainRouterVO> routers) {
10751075
for (final DomainRouterVO router : routers) {
10761076
final List<Long> routerGuestNtwkIds = _routerDao.getRouterNetworks(router.getId());
10771077

1078-
for (final Long routerGuestNtwkId : routerGuestNtwkIds) {
1078+
final Long vpcId = router.getVpcId();
1079+
if (vpcId != null || routerGuestNtwkIds.size() > 0) {
1080+
Long routerGuestNtwkId = vpcId != null ? vpcId : routerGuestNtwkIds.get(0);
10791081
if (router.getRedundantState() == RedundantState.MASTER) {
10801082
if (networkRouterMaps.containsKey(routerGuestNtwkId)) {
10811083
final DomainRouterVO dupRouter = networkRouterMaps.get(routerGuestNtwkId);
@@ -1084,7 +1086,6 @@ private void checkDuplicateMaster(final List<DomainRouterVO> routers) {
10841086
final String context = "Virtual router (name: " + router.getHostName() + ", id: " + router.getId() + " and router (name: " + dupRouter.getHostName()
10851087
+ ", id: " + router.getId() + ") are both in MASTER state! If the problem persist, restart both of routers. ";
10861088
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER, router.getDataCenterId(), router.getPodIdToDeployIn(), title, context);
1087-
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER, dupRouter.getDataCenterId(), dupRouter.getPodIdToDeployIn(), title, context);
10881089
s_logger.warn(context);
10891090
} else {
10901091
networkRouterMaps.put(routerGuestNtwkId, router);
@@ -1168,8 +1169,14 @@ protected void runInContext() {
11681169

11691170
updateSite2SiteVpnConnectionState(routers);
11701171

1171-
List<NetworkVO> networks = _networkDao.listVpcNetworks();
1172-
s_logger.debug("Found " + networks.size() + " VPC networks to update Redundant State. ");
1172+
List<NetworkVO> networks = new ArrayList<>();
1173+
for (Vpc vpc : _vpcDao.listAll()) {
1174+
List<NetworkVO> vpcNetworks = _networkDao.listByVpc(vpc.getId());
1175+
if (vpcNetworks.size() > 0) {
1176+
networks.add(vpcNetworks.get(0));
1177+
}
1178+
}
1179+
s_logger.debug("Found " + networks.size() + " VPC's to update Redundant State. ");
11731180
pushToUpdateQueue(networks);
11741181

11751182
networks = _networkDao.listRedundantNetworks();

0 commit comments

Comments
 (0)