mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-7553: Clean up cached agentMap and pingMap in case of agents
connecting back to a different MS.
This commit is contained in:
parent
e6b8aedc54
commit
d5a8f1d875
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue