Skip to content

Commit 090db05

Browse files
committed
CLOUDSTACK-8666: Put host in Alert state only after alert.wait timeout
Instead of putting the host to Alert state immediately, the investigators should be allowed to run for some time based on alert.wait global config. At the end of this interval if the host state still cannot be determined then put the host in Alert. Also updated some of the log messages. This closes apache#621
1 parent 7febdb5 commit 090db05

2 files changed

Lines changed: 19 additions & 15 deletions

File tree

‎engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java‎

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -824,36 +824,41 @@ protected boolean handleDisconnectWithInvestigation(final AgentAttache attache,
824824
/* OK, we are going to the bad status, let's see what happened */
825825
s_logger.info("Investigating why host " + hostId + " has disconnected with event " + event);
826826

827-
final Status determinedState = investigate(attache);
827+
Status determinedState = investigate(attache);
828828
// if state cannot be determined do nothing and bail out
829829
if (determinedState == null) {
830-
s_logger.warn("Agent state cannot be determined, do nothing");
831-
return false;
830+
if (((System.currentTimeMillis() >> 10) - host.getLastPinged()) > AlertWait.value()) {
831+
s_logger.warn("Agent " + hostId + " state cannot be determined for more than " + AlertWait + "(" + AlertWait.value() + ") seconds, will go to Alert state");
832+
determinedState = Status.Alert;
833+
} else {
834+
s_logger.warn("Agent " + hostId + " state cannot be determined, do nothing");
835+
return false;
836+
}
832837
}
833838

834839
final Status currentStatus = host.getStatus();
835-
s_logger.info("The state determined is " + determinedState);
840+
s_logger.info("The agent " + hostId + " state determined is " + determinedState);
836841

837842
if (determinedState == Status.Down) {
838-
s_logger.error("Host is down: " + host.getId() + "-" + host.getName() + ". Starting HA on the VMs");
843+
String message = "Host is down: " + host.getId() + "-" + host.getName() + ". Starting HA on the VMs";
844+
s_logger.error(message);
839845
if (host.getType() != Host.Type.SecondaryStorage && host.getType() != Host.Type.ConsoleProxy) {
840-
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host disconnected, " + host.getId(),
841-
"Host is down: " + host.getId() + "-" + host.getName() + ". Starting HA on the VMs");
846+
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host down, " + host.getId(), message);
842847
}
843848
event = Status.Event.HostDown;
844849
} else if (determinedState == Status.Up) {
845-
/* Got ping response from host, bring it back*/
850+
/* Got ping response from host, bring it back */
846851
s_logger.info("Agent is determined to be up and running");
847852
agentStatusTransitTo(host, Status.Event.Ping, _nodeId);
848853
return false;
849854
} else if (determinedState == Status.Disconnected) {
850855
s_logger.warn("Agent is disconnected but the host is still up: " + host.getId() + "-" + host.getName());
851856
if (currentStatus == Status.Disconnected) {
852857
if ((System.currentTimeMillis() >> 10) - host.getLastPinged() > AlertWait.value()) {
853-
s_logger.warn("Host " + host.getId() + " has been disconnected pass the time it should be disconnected.");
858+
s_logger.warn("Host " + host.getId() + " has been disconnected past the wait time it should be disconnected.");
854859
event = Status.Event.WaitedTooLong;
855860
} else {
856-
s_logger.debug("Host has been determined to be disconnected but it hasn't passed the wait time yet.");
861+
s_logger.debug("Host " + host.getId() + " has been determined to be disconnected but it hasn't passed the wait time yet.");
857862
return false;
858863
}
859864
} else if (currentStatus == Status.Up) {
@@ -862,7 +867,7 @@ protected boolean handleDisconnectWithInvestigation(final AgentAttache attache,
862867
final String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
863868
if (host.getType() != Host.Type.SecondaryStorage && host.getType() != Host.Type.ConsoleProxy) {
864869
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host disconnected, " + hostDesc,
865-
"If the agent for host [" + hostDesc + "] is not restarted within " + AlertWait + " seconds, HA will begin on the VMs");
870+
"If the agent for host [" + hostDesc + "] is not restarted within " + AlertWait + " seconds, host will go to Alert state");
866871
}
867872
event = Status.Event.AgentDisconnected;
868873
}
@@ -872,11 +877,10 @@ protected boolean handleDisconnectWithInvestigation(final AgentAttache attache,
872877
final HostPodVO podVO = _podDao.findById(host.getPodId());
873878
final String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
874879
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host in ALERT state, " + hostDesc,
875-
"In availability zone " + host.getDataCenterId() + ", " + host.getId() + "-" + host.getName()
876-
+ " disconnect due to event " + event + ", ms can't determine the host status" );
880+
"In availability zone " + host.getDataCenterId() + ", host is in alert state: " + host.getId() + "-" + host.getName());
877881
}
878882
} else {
879-
s_logger.debug("The next status of Agent " + host.getId() + " is not Alert, no need to investigate what happened");
883+
s_logger.debug("The next status of agent " + host.getId() + " is not Alert, no need to investigate what happened");
880884
}
881885
}
882886
handleDisconnectWithoutInvestigation(attache, event, true, true);

‎server/src/com/cloud/ha/HighAvailabilityManagerImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public Status investigate(final long hostId) {
220220
}
221221
}
222222

223-
return Status.Alert;
223+
return hostState;
224224
}
225225

226226
@Override

0 commit comments

Comments
 (0)