From ba2c6695cc9a1422e90cda3b517d64b22a0bc057 Mon Sep 17 00:00:00 2001 From: alena Date: Wed, 7 Sep 2011 12:47:25 -0700 Subject: [PATCH] bug 11326: don't try to transfer the agent if it's a forward agent status 11326: resolved fixed Also added more logging to the agent rebalance code. Conflicts: server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java --- .../manager/ClusteredAgentManagerImpl.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java index bb9a3c0ae57..d34f16a8681 100755 --- a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java @@ -878,6 +878,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust // if the thread: // 1) timed out waiting for the host to reconnect // 2) recipient management server is not active any more + // 3) if the management server doesn't own the host any more // remove the host from re-balance list and delete from op_host_transfer DB // no need to do anything with the real attache as we haven't modified it yet Date cutTime = DateUtil.currentGMTTime(); @@ -886,7 +887,14 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust iterator.remove(); _hostTransferDao.completeAgentTransfer(hostId); continue; - } + } + + if (attache.forForward()) { + s_logger.debug("Management server " + _nodeId + " doesn't own host id=" + hostId + " any more, skipping rebalance for the host"); + iterator.remove(); + _hostTransferDao.completeAgentTransfer(hostId); + continue; + } HostTransferMapVO transferMap = _hostTransferDao.findByIdAndCurrentOwnerId(hostId, _nodeId); @@ -1017,9 +1025,10 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust logD(requestToTransfer.getBytes(), "Failed to route request to peer"); } - requestToTransfer = forwardAttache.getRequestToTransfer(); - } - s_logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance"); + requestToTransfer = forwardAttache.getRequestToTransfer(); + } + + s_logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance to " + futureOwnerId); } else { failRebalance(hostId);