Skip to content

Commit 279e9cb

Browse files
author
Jayapal
committed
CLOUDSTACK-5552 fixed private gateway DB clean up on router upgrade required
1 parent 14ecb4f commit 279e9cb

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3897,8 +3897,9 @@ protected String getRouterControlIp(long routerId) {
38973897
List<NicVO> nics = _nicDao.listByVmId(routerId);
38983898
for (NicVO n : nics) {
38993899
NetworkVO nc = _networkDao.findById(n.getNetworkId());
3900-
if (nc.getTrafficType() == TrafficType.Control) {
3900+
if (nc !=null && nc.getTrafficType() == TrafficType.Control) {
39013901
routerControlIpAddress = n.getIp4Address();
3902+
break;
39023903
}
39033904
}
39043905

@@ -4088,7 +4089,7 @@ public List<Long> upgradeRouterTemplate(UpgradeRouterTemplateCmd cmd){
40884089

40894090
//Checks if the router is at the required version
40904091
// Compares MS version and router version
4091-
private boolean checkRouterVersion(VirtualRouter router){
4092+
protected boolean checkRouterVersion(VirtualRouter router){
40924093
if(!routerVersionCheckEnabled.value()){
40934094
//Router version check is disabled.
40944095
return true;

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,11 @@ public boolean setupPrivateGateway(PrivateGateway gateway, VirtualRouter router)
914914
try {
915915
Network network = _networkModel.getNetwork(gateway.getNetworkId());
916916
NicProfile requested = createPrivateNicProfileForGateway(gateway);
917+
918+
if (!checkRouterVersion(router)) {
919+
s_logger.warn("Router requires upgrade. Unable to send command to router: " + router.getId());
920+
return false;
921+
}
917922

918923
NicProfile guestNic = _itMgr.addVmToNetwork(router, network, requested);
919924

@@ -963,12 +968,17 @@ protected boolean setupVpcPrivateNetwork(VirtualRouter router, boolean add, NicP
963968
privateIps.add(ip);
964969
Commands cmds = new Commands(Command.OnError.Stop);
965970
createVpcAssociatePrivateIPCommands(router, privateIps, cmds, add);
966-
967-
if (sendCommandsToRouter(router, cmds)) {
968-
s_logger.debug("Successfully applied ip association for ip " + ip + " in vpc network " + network);
969-
return true;
970-
} else {
971-
s_logger.warn("Failed to associate ip address " + ip + " in vpc network " + network);
971+
972+
try{
973+
if (sendCommandsToRouter(router, cmds)) {
974+
s_logger.debug("Successfully applied ip association for ip " + ip + " in vpc network " + network);
975+
return true;
976+
} else {
977+
s_logger.warn("Failed to associate ip address " + ip + " in vpc network " + network);
978+
return false;
979+
}
980+
}catch (Exception ex) {
981+
s_logger.warn("Failed to send " + (add ?"add ":"delete ") + " private network " + network + " commands to rotuer ");
972982
return false;
973983
}
974984
} else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {

‎server/src/com/cloud/network/vpc/VpcManagerImpl.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,8 @@ public PrivateGateway applyVpcPrivateGateway(long gatewayId, boolean destroyOnFa
15131513
if (!success) {
15141514
if (destroyOnFailure) {
15151515
s_logger.debug("Destroying private gateway " + vo + " that failed to start");
1516-
if (deleteVpcPrivateGateway(gatewayId)) {
1516+
// calling deleting from db because on createprivategateway fail, destroyPrivateGateway is already called
1517+
if (deletePrivateGatewayFromTheDB(getVpcPrivateGateway(gatewayId))) {
15171518
s_logger.warn("Successfully destroyed vpc " + vo + " that failed to start");
15181519
} else {
15191520
s_logger.warn("Failed to destroy vpc " + vo + " that failed to start");

0 commit comments

Comments
 (0)