Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/src/com/cloud/host/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public enum Status {
Alert(true, true, true),
Removed(true, false, true),
Error(true, false, true),
Rebalancing(true, false, true);
Rebalancing(true, false, true),
Unknown(false, false, false); // null

private final boolean updateManagementServer;
private final boolean checkManagementServer;
Expand Down
17 changes: 9 additions & 8 deletions server/src/com/cloud/ha/AbstractInvestigatorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ protected List<Long> findHostByPod(long podId, Long excludeHostId) {
return hostIds;
}

// Method only returns Status.Up, Status.Down and Status.Unknown
protected Status testIpAddress(Long hostId, String testHostIp) {
try {
Answer pingTestAnswer = _agentMgr.send(hostId, new PingTestCommand(testHostIp));
if (pingTestAnswer == null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("host (" + testHostIp + ") returns null answer");
s_logger.debug("host (" + testHostIp + ") returns Unknown (null) answer");
}
return Status.Alert;
return Status.Unknown;
}

if (pingTestAnswer.getResult()) {
Expand All @@ -103,20 +104,20 @@ protected Status testIpAddress(Long hostId, String testHostIp) {
return Status.Up;
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("host (" + testHostIp + ") cannot be pinged, returning Alert state");
s_logger.debug("host (" + testHostIp + ") cannot be pinged, returning Unknown (I don't know) state");
}
return Status.Alert;
return Status.Unknown;
}
} catch (AgentUnavailableException e) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("host (" + testHostIp + "): " + e.getLocalizedMessage() + ", returning Disconnected state");
s_logger.debug("host (" + testHostIp + "): " + e.getLocalizedMessage() + ", trapped AgentUnavailableException returning Unknown state");
}
return Status.Disconnected;
return Status.Unknown;
} catch (OperationTimedoutException e) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("host (" + testHostIp + "): " + e.getLocalizedMessage() + ", returning Alert state");
s_logger.debug("host (" + testHostIp + "): " + e.getLocalizedMessage() + ", trapped OperationTimedoutException returning Unknown state");
}
return Status.Alert;
return Status.Unknown;
}
}
}
9 changes: 4 additions & 5 deletions server/src/com/cloud/ha/ManagementIPSystemVMInvestigator.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ public Boolean isVmAlive(VirtualMachine vm, Host host) {
List<Long> otherHosts = findHostByPod(vmHost.getPodId(), vm.getHostId());
for (Long otherHost : otherHosts) {
Status vmState = testIpAddress(otherHost, nic.getIp4Address());
if (vmState == null) {
// can't get information from that host, try the next one
continue;
}
assert vmState != null;
// In case of Status.Unknown, next host will be tried
if (vmState == Status.Up) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("successfully pinged vm's private IP (" + vm.getPrivateIpAddress() + "), returning that the VM is up");
Expand All @@ -91,7 +89,8 @@ public Boolean isVmAlive(VirtualMachine vm, Host host) {
// We can't ping the VM directly...if we can ping the host, then report the VM down.
// If we can't ping the host, then we don't have enough information.
Status vmHostState = testIpAddress(otherHost, vmHost.getPrivateIpAddress());
if ((vmHostState != null) && (vmHostState == Status.Up)) {
assert vmHostState != null;
if (vmHostState == Status.Up) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("successfully pinged vm's host IP (" + vmHost.getPrivateIpAddress() +
"), but could not ping VM, returning that the VM is down");
Expand Down
8 changes: 3 additions & 5 deletions server/src/com/cloud/ha/UserVmDomRInvestigator.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,12 @@ public Status isAgentAlive(Host agent) {
List<Long> otherHosts = findHostByPod(agent.getPodId(), agent.getId());

for (Long hostId : otherHosts) {

if (s_logger.isDebugEnabled()) {
s_logger.debug("sending ping from (" + hostId + ") to agent's host ip address (" + agent.getPrivateIpAddress() + ")");
}
Status hostState = testIpAddress(hostId, agent.getPrivateIpAddress());
if (hostState == null) {
continue;
}
assert hostState != null;
// In case of Status.Unknown, next host will be tried
if (hostState == Status.Up) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("ping from (" + hostId + ") to agent's host ip address (" + agent.getPrivateIpAddress() +
Expand All @@ -134,7 +132,7 @@ public Status isAgentAlive(Host agent) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("returning host state: " + hostState);
}
return hostState;
return Status.Down;
}
}

Expand Down