From 7e30e3d141fb5b5096022c4c56246acfa1d3d505 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Fri, 28 Feb 2020 09:54:12 +0100 Subject: [PATCH] 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 --- .../VirtualNetworkApplianceManagerImpl.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 2fad41ed6da..b58f505213f 100644 --- a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1075,7 +1075,9 @@ Configurable, StateListener routerGuestNtwkIds = _routerDao.getRouterNetworks(router.getId()); - for (final Long routerGuestNtwkId : routerGuestNtwkIds) { + final Long vpcId = router.getVpcId(); + if (vpcId != null || routerGuestNtwkIds.size() > 0) { + Long routerGuestNtwkId = vpcId != null ? vpcId : routerGuestNtwkIds.get(0); if (router.getRedundantState() == RedundantState.MASTER) { if (networkRouterMaps.containsKey(routerGuestNtwkId)) { final DomainRouterVO dupRouter = networkRouterMaps.get(routerGuestNtwkId); @@ -1084,7 +1086,6 @@ Configurable, StateListener networks = _networkDao.listVpcNetworks(); - s_logger.debug("Found " + networks.size() + " VPC networks to update Redundant State. "); + List networks = new ArrayList<>(); + for (Vpc vpc : _vpcDao.listAll()) { + List vpcNetworks = _networkDao.listByVpc(vpc.getId()); + if (vpcNetworks.size() > 0) { + networks.add(vpcNetworks.get(0)); + } + } + s_logger.debug("Found " + networks.size() + " VPC's to update Redundant State. "); pushToUpdateQueue(networks); networks = _networkDao.listRedundantNetworks();