From ca9deb70f6670280af22d09203047f0cef35ffe0 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 5 Feb 2015 10:06:02 +0100 Subject: [PATCH] Fix the router id on the virtural routers - Using the VPC id, it is reliable. - Tested stopping/destroying/creating a router and VRRP is pretty happy --- .../router/VirtualNetworkApplianceManagerImpl.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 5bca748700a..61fa9189d9b 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -693,13 +693,13 @@ Configurable, StateListener { } // We cannot schedule a job at specific time. Provide initial delay instead, from current time, so that the job runs at desired time - long initialDelay = aggDate - System.currentTimeMillis(); + final long initialDelay = aggDate - System.currentTimeMillis(); if( initialDelay < 0){ s_logger.warn("Initial delay for network usage stats update task is incorrect. Stats update task will run immediately"); } - _networkStatsUpdateExecutor.scheduleAtFixedRate(new NetworkStatsUpdateTask(), initialDelay, (_usageAggregationRange * 60 * 1000), + _networkStatsUpdateExecutor.scheduleAtFixedRate(new NetworkStatsUpdateTask(), initialDelay, _usageAggregationRange * 60 * 1000, TimeUnit.MILLISECONDS); if (_routerCheckInterval > 0) { @@ -1595,6 +1595,9 @@ Configurable, StateListener { final List routers; if (vpcId != null) { routers = _routerDao.listByVpcId(vpcId); + // For a redundant VPC router, both shall have the same router id. It will be used by the VRRP virtural_router_id attribute. + // So we use the VPC id to avoid group problems. + buf.append(" router_id=").append(vpcId); } else { routers = _routerDao.listByNetworkAndRole(nic.getNetworkId(), Role.VIRTUAL_ROUTER); } @@ -1604,14 +1607,8 @@ Configurable, StateListener { if (routers.size() == 0) { redundantState = RedundantState.MASTER.toString(); router.setRedundantState(RedundantState.MASTER); - - buf.append(" router_id=").append(router.getId()); } else { final DomainRouterVO router0 = routers.get(0); - - //For a redundant router, both shall have the same router id. It will be used by the VRRP virtural_router_id attribute. - buf.append(" router_id=").append(router0.getId()); - if (router.getId() == router0.getId()) { redundantState = RedundantState.MASTER.toString(); router.setRedundantState(RedundantState.MASTER);