be more responsible if we decide the agent should not connect

This commit is contained in:
Alex Huang 2011-05-04 18:48:58 -07:00
parent aa25cfa676
commit 9b784edec4
2 changed files with 6 additions and 3 deletions

View File

@ -1707,6 +1707,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
HostVO host = _hostDao.findById(id);
if (!_hostDao.directConnect(host, _nodeId)) {
s_logger.info("Someone else is loading " + host);
resource.disconnected();
return null;
}
}

View File

@ -686,7 +686,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
} catch (OperationTimedoutException e) {
s_logger.debug("Unable to send the start command to host " + dest.getHost());
if (e.isActive()) {
_haMgr.scheduleStop(vm, destHostId, WorkType.ForceStop);
_haMgr.scheduleStop(vm, destHostId, WorkType.CheckStop);
}
canRetry = false;
throw new AgentUnavailableException("Unable to start " + vm.getHostName(), destHostId, e);
@ -720,12 +720,14 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
}
}
} finally {
if (startedVm == null && canRetry) {
if (startedVm == null) {
// decrement only for user VM's and newly created VM
if (vm.getType().equals(VirtualMachine.Type.User) && (vm.getLastHostId() == null)) {
_accountMgr.decrementResourceCount(vm.getAccountId(), ResourceType.user_vm);
}
changeState(vm, Event.OperationFailed, null, work, Step.Done);
if (canRetry) {
changeState(vm, Event.OperationFailed, null, work, Step.Done);
}
}
}