anuragaw commented on a change in pull request #3421: RvR: VPC redundant vrs
run on same hypervisor
URL: https://github.com/apache/cloudstack/pull/3421#discussion_r297597288
##########
File path: server/src/com/cloud/network/router/NetworkHelperImpl.java
##########
@@ -388,6 +388,19 @@ public DomainRouterVO startVirtualRouter(final
DomainRouterVO router, final User
routerToBeAvoid = rrouter;
}
}
+ } else if (router.getVpcId() != null) {
+ final List<DomainRouterVO> routerList =
_routerDao.listByVpcId(router.getVpcId());
+ for (final DomainRouterVO rrouter : routerList) {
+ if (rrouter.getHostId() != null &&
rrouter.getIsRedundantRouter() && rrouter.getState() == State.Running) {
+ if (routerToBeAvoid != null) {
+ throw new ResourceUnavailableException("Try to start
router " + router.getInstanceName() + "(" + router.getId() + ")"
+ + ", but there are already two redundant
routers with IP " + router.getPublicIpAddress() + ", they are " +
rrouter.getInstanceName() + "("
+ + rrouter.getId() + ") and " +
routerToBeAvoid.getInstanceName() + "(" + routerToBeAvoid.getId() + ")",
DataCenter.class,
+ rrouter.getDataCenterId());
+ }
+ routerToBeAvoid = rrouter;
+ }
+ }
Review comment:
nit - This could use clean up to avoid duplication of logic and fixing at
multiple places -
```
DomainRouterVO routerToBeAvoid = null;
List<DomainRouterVO> routerList = ;
if (networkIds.size() != 0) {
routerList = _routerDao.findByNetwork(networkIds.get(0));
} else if (router.getVpcId() != null) {
routerList = _routerDao.listByVpcId(router.getVpcId());
}
if (CollectionUtils.isNotEmpty(routerList) {
for (final DomainRouterVO rrouter : routerList) {
if (rrouter.getHostId() != null &&
rrouter.getIsRedundantRouter() && rrouter.getState() == State.Running) {
if (routerToBeAvoid != null) {
throw new ResourceUnavailableException("Try to start
router " + router.getInstanceName() + "(" + router.getId() + ")"
+ ", but there are already two redundant
routers with IP " + router.getPublicIpAddress() + ", they are " +
rrouter.getInstanceName() + "("
+ rrouter.getId() + ") and " +
routerToBeAvoid.getInstanceName() + "(" + routerToBeAvoid.getId() + ")",
DataCenter.class,
rrouter.getDataCenterId());
}
routerToBeAvoid = rrouter;
}
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services