agent: don't investigate if host is null, send alert instead

Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fb1069ac
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fb1069ac
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fb1069ac

Branch: refs/heads/4.5
Commit: fb1069ace9cdb94f09bf7a6e51453a446b8ac25d
Parents: 419508b
Author: Rohit Yadav <rohit.ya...@shapeblue.com>
Authored: Thu Feb 5 16:42:13 2015 +0530
Committer: Rohit Yadav <rohit.ya...@shapeblue.com>
Committed: Thu Feb 5 16:42:56 2015 +0530

----------------------------------------------------------------------
 .../cloud/agent/manager/AgentManagerImpl.java   | 24 +++++++++++---------
 1 file changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fb1069ac/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java 
b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
index 105a82d..918476c 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -438,20 +438,22 @@ public class AgentManagerImpl extends ManagerBase 
implements AgentManager, Handl
 
     protected Status investigate(AgentAttache agent) {
         Long hostId = agent.getId();
-        if (s_logger.isDebugEnabled()) {
-            s_logger.debug("checking if agent (" + hostId + ") is alive");
-        }
-
-        Answer answer = easySend(hostId, new CheckHealthCommand());
-        if (answer != null && answer.getResult()) {
-            Status status = Status.Up;
+        HostVO host = _hostDao.findById(hostId);
+        if (host != null && host.getType() != null && 
!host.getType().isVirtual()) {
             if (s_logger.isDebugEnabled()) {
-                s_logger.debug("agent (" + hostId + ") responded to 
checkHeathCommand, reporting that agent is " + status);
+                s_logger.debug("checking if agent (" + hostId + ") is alive");
             }
-            return status;
+            Answer answer = easySend(hostId, new CheckHealthCommand());
+            if (answer != null && answer.getResult()) {
+                Status status = Status.Up;
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("agent (" + hostId + ") responded to 
checkHeathCommand, reporting that agent is " + status);
+                }
+                return status;
+            }
+            return _haMgr.investigate(hostId);
         }
-
-        return _haMgr.investigate(hostId);
+        return Status.Alert;
     }
 
     protected AgentAttache getAttache(final Long hostId) throws 
AgentUnavailableException {

Reply via email to