You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2014/09/16 02:50:42 UTC
git commit: updated refs/heads/master to d5a8f1d
Repository: cloudstack
Updated Branches:
refs/heads/master e6b8aedc5 -> d5a8f1d87
CLOUDSTACK-7553: Clean up cached agentMap and pingMap in case of agents
connecting back to a different MS.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d5a8f1d8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d5a8f1d8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d5a8f1d8
Branch: refs/heads/master
Commit: d5a8f1d875667dcab6130b214029f2ec74603db0
Parents: e6b8aed
Author: Min Chen <mi...@citrix.com>
Authored: Mon Sep 15 17:37:51 2014 -0700
Committer: Min Chen <mi...@citrix.com>
Committed: Mon Sep 15 17:37:51 2014 -0700
----------------------------------------------------------------------
.../com/cloud/agent/manager/AgentManagerImpl.java | 16 ++++++++++++++++
.../agent/manager/ClusteredAgentManagerImpl.java | 12 +++++++++---
2 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d5a8f1d8/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 f1f6eb9..2d5eb2b 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -1387,6 +1387,22 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
_executor.submit(new DisconnectTask(attache, event, true));
}
+ protected boolean isHostOwnerSwitched(final long hostId) {
+ HostVO host = _hostDao.findById(hostId);
+ if (host == null) {
+ s_logger.warn("Can't find the host " + hostId);
+ return false;
+ }
+ return isHostOwnerSwitched(host);
+ }
+
+ protected boolean isHostOwnerSwitched(HostVO host) {
+ if (host.getStatus() == Status.Up && host.getManagementServerId() != null && host.getManagementServerId() != _nodeId) {
+ return true;
+ }
+ return false;
+ }
+
private void disconnectInternal(final long hostId, final Status.Event event, boolean invstigate) {
AgentAttache attache = findAttache(hostId);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d5a8f1d8/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
index 5c6319d..bf28e2b 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
@@ -254,7 +254,10 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
_agents.put(id, attache);
}
if (old != null) {
- old.disconnect(Status.Removed);
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Remove stale agent attache from current management server");
+ }
+ removeAgent(old, Status.Removed);
}
return attache;
}
@@ -547,8 +550,11 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
AgentAttache agent = findAttache(hostId);
- if (agent == null) {
- if (host.getStatus() == Status.Up && (host.getManagementServerId() != null && host.getManagementServerId() != _nodeId)) {
+ if (agent == null || !agent.forForward()) {
+ if (isHostOwnerSwitched(host)) {
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Host " + hostId + " has switched to another management server, need to update agent map with a forwarding agent attache");
+ }
agent = createAttache(hostId);
}
}