bug 10567: In Basic zone, throw an exception with Pod scope when vm failed to be added to the network - so we retry to start it in a different pod

This commit is contained in:
alena 2011-08-15 11:17:30 -07:00
parent 3945eec0df
commit 8f3e83d2bc
1 changed files with 17 additions and 2 deletions

View File

@ -76,6 +76,7 @@ import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.Pod;
import com.cloud.dc.dao.AccountVlanMapDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao;
@ -1657,9 +1658,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
//for basic zone:
//1) send vm data/password information only to the dhcp in the same pod
//2) send dhcp/dns information to all routers in the cloudstack only when _dnsBasicZoneUpdates is set to "all" value
Long podId = null;
if (isZoneBasic) {
Long podId = dest.getPod().getId();
podId = dest.getPod().getId();
if (router.getPodIdToDeployIn().longValue() != podId.longValue()) {
sendPasswordAndVmData = false;
if (_dnsBasicZoneUpdates.equalsIgnoreCase("pod")) {
@ -1716,6 +1717,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
if (cmds.size() > 0) {
boolean podLevelException = false;
//for user vm in Basic zone we should try to re-deploy vm in a diff pod if it fails to deploy in original pod; so throwing exception with Pod scope
if (isZoneBasic && podId != null && profile.getVirtualMachine().getType() == VirtualMachine.Type.User && network.getTrafficType() == TrafficType.Guest && network.getGuestType() == GuestIpType.Direct) {
podLevelException = true;
}
try {
_agentMgr.send(router.getHostId(), cmds);
} catch (OperationTimedoutException e) {
@ -1725,18 +1731,27 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
Answer answer = cmds.getAnswer("dhcp");
if (!answer.getResult()) {
s_logger.error("Unable to set dhcp entry for " + profile + " on domR: " + router.getHostName() + " due to " + answer.getDetails());
if (podLevelException) {
throw new ResourceUnavailableException("Unable to set dhcp entry for " + profile + " due to " + answer.getDetails(), Pod.class, podId);
}
throw new ResourceUnavailableException("Unable to set dhcp entry for " + profile + " due to " + answer.getDetails(), DataCenter.class, router.getDataCenterIdToDeployIn());
}
answer = cmds.getAnswer("password");
if (answer != null && !answer.getResult()) {
s_logger.error("Unable to set password for " + profile + " due to " + answer.getDetails());
if (podLevelException) {
throw new ResourceUnavailableException("Unable to set password due to " + answer.getDetails(), Pod.class, podId);
}
throw new ResourceUnavailableException("Unable to set password due to " + answer.getDetails(), DataCenter.class, router.getDataCenterIdToDeployIn());
}
answer = cmds.getAnswer("vmdata");
if (answer != null && !answer.getResult()) {
s_logger.error("Unable to set VM data for " + profile + " due to " + answer.getDetails());
if (podLevelException) {
throw new ResourceUnavailableException("Unable to set VM data due to " + answer.getDetails(), Pod.class, podId);
}
throw new ResourceUnavailableException("Unable to set VM data due to " + answer.getDetails(), DataCenter.class, router.getDataCenterIdToDeployIn());
}
}