Skip to content

Commit 36babbf

Browse files
author
Alena Prokharchyk
committed
CS-16213: agent LB - don't process Disconnect event from other management server in cluster, if the recipient is the future owner of the host. The disconnect will be handled during the rebalance host connection process itself.
Reviewed-by: Kelven Yang
1 parent 705130e commit 36babbf

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

‎server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,16 @@ public boolean executeUserRequest(long hostId, Event event) throws AgentUnavaila
305305
}
306306
AgentAttache attache = findAttache(hostId);
307307
if (attache != null) {
308+
if (_clusterMgr.isAgentRebalanceEnabled()) {
309+
//don't process disconnect if the host is being rebalanced
310+
HostTransferMapVO transferVO = _hostTransferDao.findById(hostId);
311+
if (transferVO != null) {
312+
if (transferVO.getFutureOwner() == _nodeId && transferVO.getState() == HostTransferState.TransferStarted) {
313+
s_logger.debug("Not processing disconnect event as the host is being connected to " + _nodeId);
314+
return true;
315+
}
316+
}
317+
}
308318
handleDisconnect(attache, Event.AgentDisconnected, false, false);
309319
}
310320

@@ -936,9 +946,24 @@ protected boolean rebalanceHost(final long hostId, long currentOwnerId, long fut
936946
HostVO host = _hostDao.findById(hostId);
937947
try {
938948
if (s_logger.isDebugEnabled()) {
939-
s_logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + " as a part of rebalance process");
949+
s_logger.debug("Disconnecting host " + host.getId() + "(" + host.getName() + " as a part of rebalance process without notification");
940950
}
941-
result = loadDirectlyConnectedHost(host, true);
951+
952+
AgentAttache attache = findAttache(hostId);
953+
if (attache != null) {
954+
result = handleDisconnect(attache, Event.AgentDisconnected, false, false);
955+
}
956+
957+
if (result) {
958+
if (s_logger.isDebugEnabled()) {
959+
s_logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + " as a part of rebalance process");
960+
}
961+
result = loadDirectlyConnectedHost(host, true);
962+
} else {
963+
s_logger.warn("Failed to disconnect " + host.getId() + "(" + host.getName() +
964+
" as a part of rebalance process without notification");
965+
}
966+
942967
} catch (Exception ex) {
943968
s_logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + " as a part of rebalance process due to:", ex);
944969
result = false;

0 commit comments

Comments
 (0)