mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
move HA rescheduling operation to HA worker context.
This commit is contained in:
parent
53f306e8e2
commit
3d5fbe7073
@ -267,10 +267,17 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
"] is down." +
|
||||
((sb != null) ? sb.toString() : ""));
|
||||
|
||||
for (final VMInstanceVO vm : vms) {
|
||||
for (VMInstanceVO vm : vms) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Notifying HA Mgr of to restart vm " + vm.getId() + "-" + vm.getHostName());
|
||||
}
|
||||
vm = _instanceDao.findByUuid(vm.getUuid());
|
||||
Long hostId = vm.getHostId();
|
||||
if ( hostId != null && !hostId.equals(host.getId()) ) {
|
||||
s_logger.debug("VM " + vm.getHostName() + " is not on down host " + host.getId() + " it is on other host "
|
||||
+ hostId + " VM HA is done");
|
||||
continue;
|
||||
}
|
||||
scheduleRestart(vm, investigate);
|
||||
}
|
||||
}
|
||||
@ -951,10 +958,19 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
@Override
|
||||
public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
|
||||
if (oldState == State.Running && event == VirtualMachine.Event.FollowAgentPowerOffReport && newState == State.Stopped) {
|
||||
VMInstanceVO vm = _instanceDao.findById(vo.getId());
|
||||
final VMInstanceVO vm = _instanceDao.findById(vo.getId());
|
||||
if (vm.isHaEnabled()) {
|
||||
s_logger.info("Detected out-of-band stop of a HA enabled VM " + vm.getInstanceName() + ", will schedule restart");
|
||||
scheduleRestart(vm, true);
|
||||
_executor.submit(new ManagedContextRunnable() {
|
||||
@Override
|
||||
protected void runInContext() {
|
||||
try {
|
||||
scheduleRestart(vm, true);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unexpected exception when scheduling a HA restart", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user