Skip to content

Commit 53e6825

Browse files
author
Sheng Yang
committed
CLOUDSTACK-689: Clean stop pending flags when VR start/stop
1 parent 13944a0 commit 53e6825

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,14 @@ public VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUn
501501
if(virtualRouter == null){
502502
throw new CloudRuntimeException("Failed to stop router with id " + routerId);
503503
}
504+
505+
// Clear stop pending flag after stopped successfully
506+
if (router.isStopPending()) {
507+
s_logger.info("Clear the stop pending flag of router " + router.getHostName() + " after stop router successfully");
508+
router.setStopPending(false);
509+
router = _routerDao.persist(router);
510+
virtualRouter.setStopPending(false);
511+
}
504512
return virtualRouter;
505513
}
506514

@@ -2413,6 +2421,11 @@ private DomainRouterVO start(DomainRouterVO router, User user, Account caller, M
24132421
ConcurrentOperationException, ResourceUnavailableException {
24142422
s_logger.debug("Starting router " + router);
24152423
if (_itMgr.start(router, params, user, caller, planToDeploy) != null) {
2424+
if (router.isStopPending()) {
2425+
s_logger.info("Clear the stop pending flag of router " + router.getHostName() + " after start router successfully!");
2426+
router.setStopPending(false);
2427+
router = _routerDao.persist(router);
2428+
}
24162429
// We don't want the failure of VPN Connection affect the status of router, so we try to make connection
24172430
// only after router start successfully
24182431
Long vpcId = router.getVpcId();
@@ -3308,6 +3321,7 @@ public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance
33083321
List<DomainRouterVO> routers = _routerDao.listIsolatedByHostId(host.getId());
33093322
for (DomainRouterVO router : routers) {
33103323
if (router.isStopPending()) {
3324+
s_logger.info("Stopping router " + router.getInstanceName() + " due to stop pending flag found!");
33113325
State state = router.getState();
33123326
if (state != State.Stopped && state != State.Destroyed) {
33133327
try {

0 commit comments

Comments
 (0)