bug 8383: HA: perform ssh check before marking system vms as running. For domR, also reapply all ips/PF/LB/VPN/Dhcp/Userdata.

status 8383: resolved fixed
This commit is contained in:
alena 2011-02-04 13:53:16 -08:00
parent 33d804846f
commit e9dd1ee822
7 changed files with 75 additions and 11 deletions

View File

@ -315,6 +315,12 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
// TODO Auto-generated method stub
return false;
}
@Override
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<ConsoleProxyVO> profile) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean finalizeStart(VirtualMachineProfile<ConsoleProxyVO> profile, long hostId, Commands cmds, ReservationContext context) {

View File

@ -116,6 +116,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.ConsoleProxyVO;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.SecondaryStorageVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.State;
@ -1439,9 +1440,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
@Override
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<ConsoleProxyVO> profile, DeployDestination dest, ReservationContext context) {
NicProfile controlNic = (NicProfile)profile.getParameter(VirtualMachineProfile.Param.ControlNic);
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
cmds.addCommand("checkSsh", check);
finalizeCommandsOnStart(cmds, profile);
ConsoleProxyVO proxy = profile.getVirtualMachine();
DataCenter dc = dest.getDataCenter();
@ -1460,6 +1460,15 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
return true;
}
@Override
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<ConsoleProxyVO> profile) {
NicProfile controlNic = (NicProfile)profile.getParameter(VirtualMachineProfile.Param.ControlNic);
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
cmds.addCommand("checkSsh", check);
return true;
}
@Override
public boolean finalizeStart(VirtualMachineProfile<ConsoleProxyVO> profile, long hostId, Commands cmds, ReservationContext context) {
CheckSshAnswer answer = (CheckSshAnswer)cmds.getAnswer("checkSsh");

View File

@ -964,10 +964,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
@Override
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException{
NicProfile controlNic = (NicProfile) profile.getParameter(VirtualMachineProfile.Param.ControlNic);
cmds.addCommand("checkSsh", new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20));
DomainRouterVO router = profile.getVirtualMachine();
List<NicProfile> nics = profile.getNics();
@ -985,6 +981,16 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
_routerDao.update(router.getId(), router);
finalizeCommandsOnStart(cmds, profile);
return true;
}
@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));
//restart network if restartNetwork = false is not specified in profile parameters
boolean restartNetwork = true;
if (profile.getParameter(Param.RestartNetwork) != null && (Boolean)profile.getParameter(Param.RestartNetwork) == false) {

View File

@ -1046,9 +1046,8 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
@Override
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<SecondaryStorageVmVO> profile, DeployDestination dest,
ReservationContext context) {
NicProfile controlNic = (NicProfile) profile.getParameter(VirtualMachineProfile.Param.ControlNic);
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
cmds.addCommand("checkSsh", check);
finalizeCommandsOnStart(cmds, profile);
SecondaryStorageVmVO secVm = profile.getVirtualMachine();
DataCenter dc = dest.getDataCenter();
@ -1068,6 +1067,15 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
return true;
}
@Override
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<SecondaryStorageVmVO> profile) {
NicProfile controlNic = (NicProfile) profile.getParameter(VirtualMachineProfile.Param.ControlNic);
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
cmds.addCommand("checkSsh", check);
return true;
}
@Override
public boolean finalizeStart(VirtualMachineProfile<SecondaryStorageVmVO> profile, long hostId, Commands cmds, ReservationContext context) {

View File

@ -2210,6 +2210,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
_vmDao.update(userVm.getId(), userVm);
return true;
}
@Override
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<UserVmVO> profile) {
return true;
}
@Override
public boolean finalizeStart(VirtualMachineProfile<UserVmVO> profile, long hostId, Commands cmds, ReservationContext context) {

View File

@ -58,6 +58,8 @@ public interface VirtualMachineGuru<T extends VirtualMachine> {
*/
boolean finalizeStart(VirtualMachineProfile<T> profile, long hostId, Commands cmds, ReservationContext context);
boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<T> profile);
void finalizeStop(VirtualMachineProfile<T> profile, StopAnswer answer);
void finalizeExpunge(T vm);

View File

@ -1304,6 +1304,8 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, StateLi
final State serverState = vm.getState();
final String serverName = vm.getName();
VirtualMachineGuru<VMInstanceVO> vmGuru = getVmGuru(vm);
Command command = null;
if (s_logger.isDebugEnabled()) {
@ -1389,7 +1391,33 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, StateLi
s_logger.debug("VM state is starting on full sync so updating it to running");
vm = findById(vm.getType(), vm.getId());
stateTransitTo(vm, Event.AgentReportRunning, vm.getHostId());
//finalizeStart(new VirtualMachineProfileImpl<VMInstanceVO>(vm), vm.getHostId(), null, null);
s_logger.debug("VM's " + vm + " state is starting on full sync so updating it to Running");
vm = vmGuru.findById(vm.getId());
VirtualMachineProfile<VMInstanceVO> profile = new VirtualMachineProfileImpl<VMInstanceVO>(vm);
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);
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;
}
}
} else if (serverState == State.Stopping) {
if (fullSync) {