Skip to content

Commit e9dd1ee

Browse files
committed
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
1 parent 33d8048 commit e9dd1ee

7 files changed

Lines changed: 75 additions & 11 deletions

File tree

‎server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<ConsolePr
315315
// TODO Auto-generated method stub
316316
return false;
317317
}
318+
319+
@Override
320+
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<ConsoleProxyVO> profile) {
321+
// TODO Auto-generated method stub
322+
return false;
323+
}
318324

319325
@Override
320326
public boolean finalizeStart(VirtualMachineProfile<ConsoleProxyVO> profile, long hostId, Commands cmds, ReservationContext context) {

‎server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
import com.cloud.vm.ConsoleProxyVO;
117117
import com.cloud.vm.NicProfile;
118118
import com.cloud.vm.ReservationContext;
119+
import com.cloud.vm.SecondaryStorageVmVO;
119120
import com.cloud.vm.VMInstanceVO;
120121
import com.cloud.vm.VirtualMachine;
121122
import com.cloud.vm.VirtualMachine.State;
@@ -1439,9 +1440,8 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<ConsoleProxyV
14391440

14401441
@Override
14411442
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<ConsoleProxyVO> profile, DeployDestination dest, ReservationContext context) {
1442-
NicProfile controlNic = (NicProfile)profile.getParameter(VirtualMachineProfile.Param.ControlNic);
1443-
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
1444-
cmds.addCommand("checkSsh", check);
1443+
1444+
finalizeCommandsOnStart(cmds, profile);
14451445

14461446
ConsoleProxyVO proxy = profile.getVirtualMachine();
14471447
DataCenter dc = dest.getDataCenter();
@@ -1460,6 +1460,15 @@ public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<ConsolePr
14601460
return true;
14611461
}
14621462

1463+
@Override
1464+
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<ConsoleProxyVO> profile) {
1465+
NicProfile controlNic = (NicProfile)profile.getParameter(VirtualMachineProfile.Param.ControlNic);
1466+
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
1467+
cmds.addCommand("checkSsh", check);
1468+
1469+
return true;
1470+
}
1471+
14631472
@Override
14641473
public boolean finalizeStart(VirtualMachineProfile<ConsoleProxyVO> profile, long hostId, Commands cmds, ReservationContext context) {
14651474
CheckSshAnswer answer = (CheckSshAnswer)cmds.getAnswer("checkSsh");

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -964,10 +964,6 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterV
964964

965965
@Override
966966
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException{
967-
NicProfile controlNic = (NicProfile) profile.getParameter(VirtualMachineProfile.Param.ControlNic);
968-
969-
cmds.addCommand("checkSsh", new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20));
970-
971967
DomainRouterVO router = profile.getVirtualMachine();
972968

973969
List<NicProfile> nics = profile.getNics();
@@ -985,6 +981,16 @@ public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<DomainRou
985981
}
986982
_routerDao.update(router.getId(), router);
987983

984+
finalizeCommandsOnStart(cmds, profile);
985+
return true;
986+
}
987+
988+
@Override
989+
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<DomainRouterVO> profile) {
990+
DomainRouterVO router = profile.getVirtualMachine();
991+
NicProfile controlNic = (NicProfile) profile.getParameter(VirtualMachineProfile.Param.ControlNic);
992+
cmds.addCommand("checkSsh", new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20));
993+
988994
//restart network if restartNetwork = false is not specified in profile parameters
989995
boolean restartNetwork = true;
990996
if (profile.getParameter(Param.RestartNetwork) != null && (Boolean)profile.getParameter(Param.RestartNetwork) == false) {

‎server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,9 +1046,8 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<SecondaryStor
10461046
@Override
10471047
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<SecondaryStorageVmVO> profile, DeployDestination dest,
10481048
ReservationContext context) {
1049-
NicProfile controlNic = (NicProfile) profile.getParameter(VirtualMachineProfile.Param.ControlNic);
1050-
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
1051-
cmds.addCommand("checkSsh", check);
1049+
1050+
finalizeCommandsOnStart(cmds, profile);
10521051

10531052
SecondaryStorageVmVO secVm = profile.getVirtualMachine();
10541053
DataCenter dc = dest.getDataCenter();
@@ -1068,6 +1067,15 @@ public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<Secondary
10681067
return true;
10691068
}
10701069

1070+
@Override
1071+
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<SecondaryStorageVmVO> profile) {
1072+
NicProfile controlNic = (NicProfile) profile.getParameter(VirtualMachineProfile.Param.ControlNic);
1073+
CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922, 5, 20);
1074+
cmds.addCommand("checkSsh", check);
1075+
1076+
return true;
1077+
}
1078+
10711079

10721080
@Override
10731081
public boolean finalizeStart(VirtualMachineProfile<SecondaryStorageVmVO> profile, long hostId, Commands cmds, ReservationContext context) {

‎server/src/com/cloud/vm/UserVmManagerImpl.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,11 @@ public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<UserVmVO>
22102210
_vmDao.update(userVm.getId(), userVm);
22112211
return true;
22122212
}
2213+
2214+
@Override
2215+
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<UserVmVO> profile) {
2216+
return true;
2217+
}
22132218

22142219
@Override
22152220
public boolean finalizeStart(VirtualMachineProfile<UserVmVO> profile, long hostId, Commands cmds, ReservationContext context) {

‎server/src/com/cloud/vm/VirtualMachineGuru.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public interface VirtualMachineGuru<T extends VirtualMachine> {
5858
*/
5959
boolean finalizeStart(VirtualMachineProfile<T> profile, long hostId, Commands cmds, ReservationContext context);
6060

61+
boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<T> profile);
62+
6163
void finalizeStop(VirtualMachineProfile<T> profile, StopAnswer answer);
6264

6365
void finalizeExpunge(T vm);

‎server/src/com/cloud/vm/VirtualMachineManagerImpl.java‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,8 @@ protected Command compareState(VMInstanceVO vm, final AgentVmInfo info, final bo
13041304
final State serverState = vm.getState();
13051305
final String serverName = vm.getName();
13061306

1307+
VirtualMachineGuru<VMInstanceVO> vmGuru = getVmGuru(vm);
1308+
13071309
Command command = null;
13081310

13091311
if (s_logger.isDebugEnabled()) {
@@ -1389,7 +1391,33 @@ protected Command compareState(VMInstanceVO vm, final AgentVmInfo info, final bo
13891391
s_logger.debug("VM state is starting on full sync so updating it to running");
13901392
vm = findById(vm.getType(), vm.getId());
13911393
stateTransitTo(vm, Event.AgentReportRunning, vm.getHostId());
1392-
//finalizeStart(new VirtualMachineProfileImpl<VMInstanceVO>(vm), vm.getHostId(), null, null);
1394+
s_logger.debug("VM's " + vm + " state is starting on full sync so updating it to Running");
1395+
vm = vmGuru.findById(vm.getId());
1396+
1397+
VirtualMachineProfile<VMInstanceVO> profile = new VirtualMachineProfileImpl<VMInstanceVO>(vm);
1398+
1399+
Commands cmds = new Commands(OnError.Revert);
1400+
s_logger.debug("Finalizing commands that need to be send to complete Start process for the vm " + vm);
1401+
vmGuru.finalizeCommandsOnStart(cmds, profile);
1402+
1403+
if (cmds.size() != 0) {
1404+
try {
1405+
_agentMgr.send(vm.getHostId(), cmds);
1406+
} catch (OperationTimedoutException e){
1407+
s_logger.error("Exception during update for running vm: " + vm, e);
1408+
return null;
1409+
} catch (ResourceUnavailableException e) {
1410+
s_logger.error("Exception during update for running vm: " + vm, e);
1411+
return null;
1412+
}
1413+
}
1414+
1415+
if (vmGuru.finalizeStart(profile, vm.getHostId(), cmds, null)) {
1416+
stateTransitTo(vm, Event.AgentReportRunning, vm.getHostId());
1417+
} else {
1418+
s_logger.error("Exception during update for running vm: " + vm);
1419+
return null;
1420+
}
13931421
}
13941422
} else if (serverState == State.Stopping) {
13951423
if (fullSync) {

0 commit comments

Comments
 (0)