Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to propagate updated management servers list and lb algorithm in host and indirect.agent.lb.algorithm settings resp, to systemvm agents #10524

Open
wants to merge 3 commits into
base: 4.20
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
ResourceState.ErrorInMaintenance, ResourceState.PrepareForMaintenance);
private static final List<Host.Type> agentValidHostTypes = List.of(Host.Type.Routing, Host.Type.ConsoleProxy,
Host.Type.SecondaryStorage, Host.Type.SecondaryStorageVM);
private static final List<Host.Type> agentNonRoutingHostTypes = List.of(Host.Type.ConsoleProxy,
Host.Type.SecondaryStorage, Host.Type.SecondaryStorageVM);
private static final List<Hypervisor.HypervisorType> agentValidHypervisorTypes = List.of(
Hypervisor.HypervisorType.KVM, Hypervisor.HypervisorType.LXC);

Expand Down Expand Up @@ -136,6 +138,16 @@
return hostIdList;
}

private List<Long> getAllAgentBasedNonRoutingHostsFromDB(final Long zoneId) {
return hostDao.findHostIdsByZoneClusterResourceStateTypeAndHypervisorType(zoneId, null,

Check warning on line 142 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L141-L142

Added lines #L141 - L142 were not covered by tests
agentValidResourceStates, agentNonRoutingHostTypes, agentValidHypervisorTypes);
}

Check warning on line 144 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L144

Added line #L144 was not covered by tests

private List<Long> getAllAgentBasedRoutingHostsFromDB(final Long zoneId, final Long clusterId) {
return hostDao.findHostIdsByZoneClusterResourceStateTypeAndHypervisorType(zoneId, clusterId,
agentValidResourceStates, List.of(Host.Type.Routing), agentValidHypervisorTypes);
}

Check warning on line 149 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L146-L149

Added lines #L146 - L149 were not covered by tests

private List<Long> getAllAgentBasedHostsFromDB(final Long zoneId, final Long clusterId) {
return hostDao.findHostIdsByZoneClusterResourceStateTypeAndHypervisorType(zoneId, clusterId,
agentValidResourceStates, agentValidHostTypes, agentValidHypervisorTypes);
Expand All @@ -158,32 +170,42 @@
public void propagateMSListToAgents() {
logger.debug("Propagating management server list update to agents");
final String lbAlgorithm = getLBAlgorithmName();
final Long globalLbCheckInterval = getLBPreferredHostCheckInterval(null);

Check warning on line 173 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L173

Added line #L173 was not covered by tests
List<DataCenterVO> zones = dataCenterDao.listAll();
for (DataCenterVO zone : zones) {
List<Long> zoneHostIds = new ArrayList<>();
List<Long> nonRoutingHostIds = getAllAgentBasedNonRoutingHostsFromDB(zone.getId());
zoneHostIds.addAll(nonRoutingHostIds);

Check warning on line 178 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L177-L178

Added lines #L177 - L178 were not covered by tests
Map<Long, List<Long>> clusterHostIdsMap = new HashMap<>();
List<Long> clusterIds = clusterDao.listAllClusterIds(zone.getId());
for (Long clusterId : clusterIds) {
List<Long> hostIds = getAllAgentBasedHostsFromDB(zone.getId(), clusterId);
List<Long> hostIds = getAllAgentBasedRoutingHostsFromDB(zone.getId(), clusterId);

Check warning on line 182 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L182

Added line #L182 was not covered by tests
clusterHostIdsMap.put(clusterId, hostIds);
zoneHostIds.addAll(hostIds);
}
zoneHostIds.sort(Comparator.comparingLong(x -> x));
for (Long nonRoutingHostId : nonRoutingHostIds) {
setupMSList(nonRoutingHostId, zone.getId(), zoneHostIds, lbAlgorithm, globalLbCheckInterval);
}

Check warning on line 189 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L188-L189

Added lines #L188 - L189 were not covered by tests
for (Long clusterId : clusterIds) {
final Long lbCheckInterval = getLBPreferredHostCheckInterval(clusterId);
final Long clusterLbCheckInterval = getLBPreferredHostCheckInterval(clusterId);

Check warning on line 191 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L191

Added line #L191 was not covered by tests
List<Long> hostIds = clusterHostIdsMap.get(clusterId);
for (Long hostId : hostIds) {
final List<String> msList = getManagementServerList(hostId, zone.getId(), zoneHostIds);
final SetupMSListCommand cmd = new SetupMSListCommand(msList, lbAlgorithm, lbCheckInterval);
final Answer answer = agentManager.easySend(hostId, cmd);
if (answer == null || !answer.getResult()) {
logger.warn("Failed to setup management servers list to the agent of ID: {}", hostId);
}
setupMSList(hostId, zone.getId(), zoneHostIds, lbAlgorithm, clusterLbCheckInterval);

Check warning on line 194 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L194

Added line #L194 was not covered by tests
}
}
}
}

private void setupMSList(final Long hostId, final Long dcId, final List<Long> orderedHostIdList, final String lbAlgorithm, final Long lbCheckInterval) {
final List<String> msList = getManagementServerList(hostId, dcId, orderedHostIdList);
final SetupMSListCommand cmd = new SetupMSListCommand(msList, lbAlgorithm, lbCheckInterval);
final Answer answer = agentManager.easySend(hostId, cmd);

Check warning on line 203 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L200-L203

Added lines #L200 - L203 were not covered by tests
if (answer == null || !answer.getResult()) {
logger.warn(String.format("Failed to setup management servers list to the agent of ID: %d", hostId));

Check warning on line 205 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L205

Added line #L205 was not covered by tests
}
}

Check warning on line 207 in server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java#L207

Added line #L207 was not covered by tests

private void configureAlgorithmMap() {
final List<org.apache.cloudstack.agent.lb.IndirectAgentLBAlgorithm> algorithms = new ArrayList<>();
algorithms.add(new IndirectAgentLBStaticAlgorithm());
Expand Down
Loading