CLOUDSTACK-4786: Reset Redundant Router priority after all the routers are stopped

This patch would reset the priority in such condition:
1. All redundant routers are stopped, e.g. due to network GC
2. User start one VM in the network
3. The routers would be brought up with reseted priority(100 & 99).

This would resolve the issue of network GC result in lower limit of redundant router priority reached.
This commit is contained in:
Sheng Yang 2013-10-17 18:16:50 -07:00
parent c3df348264
commit 85dc65c7f7
2 changed files with 25 additions and 0 deletions

View File

@ -1412,6 +1412,26 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
throw new CloudRuntimeException(errMsg);
}
private void checkAndResetPriorityOfRedundantRouter(List<DomainRouterVO> routers) {
boolean allStopped = true;
for (DomainRouterVO router : routers) {
if (!router.getIsRedundantRouter() || router.getState() != VirtualMachine.State.Stopped) {
allStopped = false;
break;
}
}
if (!allStopped) {
return;
}
for (DomainRouterVO router : routers) {
// getUpdatedPriority() would update the value later
router.setPriority(0);
router.setIsPriorityBumpUp(false);
_routerDao.update(router.getId(), router);
}
}
@DB
protected List<DomainRouterVO> findOrDeployVirtualRouterInGuestNetwork(Network guestNetwork, DeployDestination dest, Account owner,
boolean isRedundant, Map<Param, Object> params) throws ConcurrentOperationException,
@ -1482,6 +1502,10 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
int routerCount = 1;
if (isRedundant) {
routerCount = 2;
//Check current redundant routers, if possible(all routers are stopped), reset the priority
if (routers.size() != 0) {
checkAndResetPriorityOfRedundantRouter(routers);
}
}
// If old network is redundant but new is single router, then routers.size() = 2 but routerCount = 1

View File

@ -1189,6 +1189,7 @@ change_password() {
start() {
# Clear /tmp for file lock
rm -f /tmp/*.lock
rm -f /tmp/rrouter_bumped
local hyp=$(hypervisor)
[ $? -ne 0 ] && log_it "Failed to detect hypervisor type, bailing out of early init" && exit 10
log_it "Detected that we are running inside $hyp guest"