mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4315: VPC - when fail to add nic to the VR, a) remove the nic b) remove the reference to nic from router_network_ref table. Before the fix b) was missing, and it caused NPEs when tried to apply the rules on the routers not having nic in the network
Conflicts: server/src/com/cloud/network/element/VirtualRouterElement.java server/src/com/cloud/vm/VirtualMachineManagerImpl.java
This commit is contained in:
parent
bea095fa47
commit
b727001f48
|
|
@ -28,10 +28,10 @@ import javax.inject.Inject;
|
|||
import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElementCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.PvlanSetupCommand;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.dc.DataCenter;
|
||||
|
|
@ -50,7 +50,6 @@ import com.cloud.network.Network.Service;
|
|||
import com.cloud.network.NetworkMigrationResponder;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
|
|
@ -87,7 +86,6 @@ import com.cloud.utils.db.SearchCriteriaService;
|
|||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
|
|
@ -100,22 +98,6 @@ import com.cloud.vm.dao.UserVmDao;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElementCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Local(value = {NetworkElement.class, FirewallServiceProvider.class,
|
||||
DhcpServiceProvider.class, UserDataServiceProvider.class,
|
||||
StaticNatServiceProvider.class, LoadBalancingServiceProvider.class,
|
||||
|
|
@ -390,7 +372,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
|
||||
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
|
||||
if (routers == null || routers.isEmpty()) {
|
||||
s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " +
|
||||
s_logger.debug("Virtual router elemnt doesn't need to apply lb rules on the backend; virtual " +
|
||||
"router doesn't exist in the network " + network.getId());
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -464,7 +464,6 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
|
|||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -287,23 +287,27 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
return false;
|
||||
}
|
||||
|
||||
//Check if router is a part of the Guest network
|
||||
if (!_networkModel.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
s_logger.debug("Router " + router + " is not a part of the Guest network " + network);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean result = setupVpcGuestNetwork(network, router, false, _networkModel.getNicProfile(router, network.getId(), null));
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to destroy guest network config " + network + " on router " + router);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = result && _itMgr.removeVmFromNetwork(router, network, null);
|
||||
|
||||
if (result) {
|
||||
boolean result = true;
|
||||
try {
|
||||
//Check if router is a part of the Guest network
|
||||
if (!_networkModel.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
s_logger.debug("Router " + router + " is not a part of the Guest network " + network);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = setupVpcGuestNetwork(network, router, false, _networkModel.getNicProfile(router, network.getId(), null));
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to destroy guest network config " + network + " on router " + router);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = result && _itMgr.removeVmFromNetwork(router, network, null);
|
||||
} finally {
|
||||
if (result) {
|
||||
_routerDao.removeRouterFromGuestNetwork(router.getId(), network.getId());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2799,7 +2799,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
return null;
|
||||
}
|
||||
} finally {
|
||||
if (!result) {
|
||||
if (!result){
|
||||
s_logger.debug("Removing nic " + nic + " from vm " + vmProfile.getVirtualMachine()
|
||||
+ " as nic plug failed on the backend");
|
||||
_networkMgr.removeNic(vmProfile, _nicsDao.findById(nic.getId()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue