bug 8719: fixed NPE happening during HA process - get control nic infrormation in finalizeCommandsOnStart() method instead of setting it in caller methods

status 8719: resolved fixed
This commit is contained in:
alena 2011-02-23 19:35:22 -08:00
parent 54b3fff123
commit 57f6b16cdb
4 changed files with 69 additions and 51 deletions

View File

@ -1388,8 +1388,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
externalDhcp = true;
}
NicProfile controlNic = null;
NicProfile managementNic = null;
for (NicProfile nic : profile.getNics()) {
int deviceId = nic.getDeviceId();
if(nic.getIp4Address() == null) {
@ -1410,12 +1408,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
if (nic.getTrafficType() == TrafficType.Management) {
buf.append(" localgw=").append(dest.getPod().getGateway());
managementNic = nic;
} else if (nic.getTrafficType() == TrafficType.Control) {
if(nic.getIp4Address() != null) {
controlNic = nic;
}
}
}
}
/*External DHCP mode*/
@ -1423,18 +1416,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
buf.append(" bootproto=dhcp");
}
if(controlNic == null) {
assert(managementNic != null);
controlNic = managementNic;
}
String bootArgs = buf.toString();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Boot Args for " + profile + ": " + bootArgs);
}
profile.setParameter(VirtualMachineProfile.Param.ControlNic, controlNic);
return true;
}
@ -1462,7 +1448,22 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
@Override
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<ConsoleProxyVO> profile) {
NicProfile controlNic = (NicProfile)profile.getParameter(VirtualMachineProfile.Param.ControlNic);
NicProfile managementNic = null;
NicProfile controlNic = null;
for (NicProfile nic : profile.getNics()) {
if (nic.getTrafficType() == TrafficType.Management) {
managementNic = nic;
} else if (nic.getTrafficType() == TrafficType.Control && nic.getIp4Address() != null) {
controlNic = nic;
}
}
if (controlNic == null) {
assert (managementNic != null);
controlNic = managementNic;
}
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
cmds.addCommand("checkSsh", check);

View File

@ -934,8 +934,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
throw new CloudRuntimeException("Didn't start a control port");
}
profile.setParameter(VirtualMachineProfile.Param.ControlNic, controlNic);
return true;
}
@ -964,9 +962,21 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
@Override
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<DomainRouterVO> profile) {
DomainRouterVO router = profile.getVirtualMachine();
NicProfile controlNic = (NicProfile) profile.getParameter(VirtualMachineProfile.Param.ControlNic);
cmds.addCommand("checkSsh", new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20));
DomainRouterVO router = profile.getVirtualMachine();
NicProfile controlNic = null;
for (NicProfile nic : profile.getNics()) {
if (nic.getTrafficType() == TrafficType.Control && nic.getIp4Address() != null) {
controlNic = nic;
}
}
if (controlNic == null) {
s_logger.error("Control network doesn't exist for the router " + router);
return false;
}
cmds.addCommand("checkSsh", new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20));
//restart network if restartNetwork = false is not specified in profile parameters
boolean restartNetwork = true;

View File

@ -984,9 +984,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
buf.append(" instance=SecStorage");
buf.append(" sslcopy=").append(Boolean.toString(_useSSlCopy));
NicProfile controlNic = null;
NicProfile managementNic = null;
boolean externalDhcp = false;
String externalDhcpStr = _configDao.getValue("direct.attach.network.externalIpAllocator.enabled");
if (externalDhcpStr != null && externalDhcpStr.equalsIgnoreCase("true")) {
@ -1009,12 +1006,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
}
if (nic.getTrafficType() == TrafficType.Management) {
buf.append(" localgw=").append(dest.getPod().getGateway());
managementNic = nic;
buf.append(" private.network.device=").append("eth").append(deviceId);
} else if (nic.getTrafficType() == TrafficType.Control) {
if (nic.getIp4Address() != null) {
controlNic = nic;
}
} else if (nic.getTrafficType() == TrafficType.Public) {
buf.append(" public.network.device=").append("eth").append(deviceId);
}
@ -1025,11 +1017,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
buf.append(" bootproto=dhcp");
}
if (controlNic == null) {
assert (managementNic != null);
controlNic = managementNic;
}
DataCenterVO dc = _dcDao.findById(profile.getVirtualMachine().getDataCenterId());
buf.append(" dns1=").append(dc.getInternalDns1());
if (dc.getInternalDns2() != null) {
@ -1041,8 +1028,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
s_logger.debug("Boot Args for " + profile + ": " + bootArgs);
}
profile.setParameter(VirtualMachineProfile.Param.ControlNic, controlNic);
return true;
}
@ -1072,7 +1057,22 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
@Override
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<SecondaryStorageVmVO> profile) {
NicProfile controlNic = (NicProfile) profile.getParameter(VirtualMachineProfile.Param.ControlNic);
NicProfile managementNic = null;
NicProfile controlNic = null;
for (NicProfile nic : profile.getNics()) {
if (nic.getTrafficType() == TrafficType.Management) {
managementNic = nic;
} else if (nic.getTrafficType() == TrafficType.Control && nic.getIp4Address() != null) {
controlNic = nic;
}
}
if (controlNic == null) {
assert (managementNic != null);
controlNic = managementNic;
}
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
cmds.addCommand("checkSsh", check);

View File

@ -1331,26 +1331,33 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
Commands cmds = new Commands(OnError.Revert);
s_logger.debug("Finalizing commands that need to be send to complete Start process for the vm " + vm);
vmGuru.finalizeCommandsOnStart(cmds, profile);
if (cmds.size() != 0) {
try {
_agentMgr.send(vm.getHostId(), cmds);
} catch (OperationTimedoutException e){
s_logger.error("Exception during update for running vm: " + vm, e);
return null;
} catch (ResourceUnavailableException e) {
s_logger.error("Exception during update for running vm: " + vm, e);
if (vmGuru.finalizeCommandsOnStart(cmds, profile)) {
if (cmds.size() != 0) {
try {
_agentMgr.send(vm.getHostId(), cmds);
} catch (OperationTimedoutException e){
s_logger.error("Exception during update for running vm: " + vm, e);
return null;
} catch (ResourceUnavailableException e) {
s_logger.error("Exception during update for running vm: " + vm, e);
return null;
}
}
if (vmGuru.finalizeStart(profile, vm.getHostId(), cmds, null)) {
stateTransitTo(vm, Event.AgentReportRunning, vm.getHostId());
} else {
s_logger.error("Exception during update for running vm: " + vm);
return null;
}
}
if (vmGuru.finalizeStart(profile, vm.getHostId(), cmds, null)) {
stateTransitTo(vm, Event.AgentReportRunning, vm.getHostId());
} else {
s_logger.error("Exception during update for running vm: " + vm);
s_logger.error("Unable to finalize commands on start for vm: " + vm);
return null;
}
}
} else if (serverState == State.Stopping) {
s_logger.debug("Scheduling a stop command for " + vm);