mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
agent: Compare indirect agent lb algorithm when cloudstack agent connects (#4335)
Compare not only the list of management servers but also the lb algorithm when agent connects. Fixes: #3895
This commit is contained in:
parent
766eab8cab
commit
534dd475d8
@ -1080,10 +1080,15 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
|||||||
ReadyCommand ready = null;
|
ReadyCommand ready = null;
|
||||||
try {
|
try {
|
||||||
final List<String> agentMSHostList = new ArrayList<>();
|
final List<String> agentMSHostList = new ArrayList<>();
|
||||||
|
String lbAlgorithm = null;
|
||||||
if (startup != null && startup.length > 0) {
|
if (startup != null && startup.length > 0) {
|
||||||
final String agentMSHosts = startup[0].getMsHostList();
|
final String agentMSHosts = startup[0].getMsHostList();
|
||||||
if (!Strings.isNullOrEmpty(agentMSHosts)) {
|
if (!Strings.isNullOrEmpty(agentMSHosts)) {
|
||||||
agentMSHostList.addAll(Arrays.asList(agentMSHosts.split(",")));
|
String[] msHosts = agentMSHosts.split("@");
|
||||||
|
if (msHosts.length > 1) {
|
||||||
|
lbAlgorithm = msHosts[1];
|
||||||
|
}
|
||||||
|
agentMSHostList.addAll(Arrays.asList(msHosts[0].split(",")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1091,7 +1096,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
|||||||
if (host != null) {
|
if (host != null) {
|
||||||
ready = new ReadyCommand(host.getDataCenterId(), host.getId());
|
ready = new ReadyCommand(host.getDataCenterId(), host.getId());
|
||||||
|
|
||||||
if (!indirectAgentLB.compareManagementServerList(host.getId(), host.getDataCenterId(), agentMSHostList)) {
|
if (!indirectAgentLB.compareManagementServerList(host.getId(), host.getDataCenterId(), agentMSHostList, lbAlgorithm)) {
|
||||||
final List<String> newMSList = indirectAgentLB.getManagementServerList(host.getId(), host.getDataCenterId(), null);
|
final List<String> newMSList = indirectAgentLB.getManagementServerList(host.getId(), host.getDataCenterId(), null);
|
||||||
ready.setMsHostList(newMSList);
|
ready.setMsHostList(newMSList);
|
||||||
ready.setLbAlgorithm(indirectAgentLB.getLBAlgorithmName());
|
ready.setLbAlgorithm(indirectAgentLB.getLBAlgorithmName());
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public interface IndirectAgentLB {
|
|||||||
* @param receivedMSHosts received management server list
|
* @param receivedMSHosts received management server list
|
||||||
* @return true if mgmtHosts is up to date, false if not
|
* @return true if mgmtHosts is up to date, false if not
|
||||||
*/
|
*/
|
||||||
boolean compareManagementServerList(Long hostId, Long dcId, List<String> receivedMSHosts);
|
boolean compareManagementServerList(Long hostId, Long dcId, List<String> receivedMSHosts, String lbAlgorithm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the configure LB algorithm
|
* Returns the configure LB algorithm
|
||||||
|
|||||||
@ -98,10 +98,13 @@ public class IndirectAgentLBServiceImpl extends ComponentLifecycleBase implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean compareManagementServerList(final Long hostId, final Long dcId, final List<String> receivedMSHosts) {
|
public boolean compareManagementServerList(final Long hostId, final Long dcId, final List<String> receivedMSHosts, final String lbAlgorithm) {
|
||||||
if (receivedMSHosts == null || receivedMSHosts.size() < 1) {
|
if (receivedMSHosts == null || receivedMSHosts.size() < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (getLBAlgorithmName() != lbAlgorithm) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
final List<String> expectedMSList = getManagementServerList(hostId, dcId, null);
|
final List<String> expectedMSList = getManagementServerList(hostId, dcId, null);
|
||||||
final org.apache.cloudstack.agent.lb.IndirectAgentLBAlgorithm algorithm = getAgentMSLBAlgorithm();
|
final org.apache.cloudstack.agent.lb.IndirectAgentLBAlgorithm algorithm = getAgentMSLBAlgorithm();
|
||||||
return algorithm.compare(expectedMSList, receivedMSHosts);
|
return algorithm.compare(expectedMSList, receivedMSHosts);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user