This is an automated email from the ASF dual-hosted git repository.

pearl11594 pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.20 by this push:
     new 33cdddfcd1b Fix to propagate updated management servers list and lb 
algorithm in host and indirect.agent.lb.algorithm settings resp, to systemvm 
agents (#10524)
33cdddfcd1b is described below

commit 33cdddfcd1bc4b630cfde041a36ab5baa20c812d
Author: Suresh Kumar Anaparti <sureshkumar.anapa...@gmail.com>
AuthorDate: Wed Mar 19 00:28:04 2025 +0530

    Fix to propagate updated management servers list and lb algorithm in host 
and indirect.agent.lb.algorithm settings resp, to systemvm agents (#10524)
    
    * propagate updated management servers list and lb algorithm in host and 
indirect.agent.lb.algorithm settings, to systemvm agents
    
    * addressed comments
    
    * addressed comments
---
 .../agent/lb/IndirectAgentLBServiceImpl.java       | 38 +++++++++++++++++-----
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git 
a/server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java
 
b/server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java
index 84c3081bfc1..d51b42ab17f 100644
--- 
a/server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java
+++ 
b/server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java
@@ -74,6 +74,8 @@ public class IndirectAgentLBServiceImpl extends 
ComponentLifecycleBase implement
             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);
 
@@ -136,6 +138,16 @@ public class IndirectAgentLBServiceImpl extends 
ComponentLifecycleBase implement
         return hostIdList;
     }
 
+    private List<Long> getAllAgentBasedNonRoutingHostsFromDB(final Long 
zoneId) {
+        return 
hostDao.findHostIdsByZoneClusterResourceStateTypeAndHypervisorType(zoneId, null,
+                agentValidResourceStates, agentNonRoutingHostTypes, 
agentValidHypervisorTypes);
+    }
+
+    private List<Long> getAllAgentBasedRoutingHostsFromDB(final Long zoneId, 
final Long clusterId) {
+        return 
hostDao.findHostIdsByZoneClusterResourceStateTypeAndHypervisorType(zoneId, 
clusterId,
+                agentValidResourceStates, List.of(Host.Type.Routing), 
agentValidHypervisorTypes);
+    }
+
     private List<Long> getAllAgentBasedHostsFromDB(final Long zoneId, final 
Long clusterId) {
         return 
hostDao.findHostIdsByZoneClusterResourceStateTypeAndHypervisorType(zoneId, 
clusterId,
                 agentValidResourceStates, agentValidHostTypes, 
agentValidHypervisorTypes);
@@ -158,32 +170,42 @@ public class IndirectAgentLBServiceImpl extends 
ComponentLifecycleBase implement
     public void propagateMSListToAgents() {
         logger.debug("Propagating management server list update to agents");
         final String lbAlgorithm = getLBAlgorithmName();
+        final Long globalLbCheckInterval = 
getLBPreferredHostCheckInterval(null);
         List<DataCenterVO> zones = dataCenterDao.listAll();
         for (DataCenterVO zone : zones) {
             List<Long> zoneHostIds = new ArrayList<>();
+            List<Long> nonRoutingHostIds = 
getAllAgentBasedNonRoutingHostsFromDB(zone.getId());
+            zoneHostIds.addAll(nonRoutingHostIds);
             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);
                 clusterHostIdsMap.put(clusterId, hostIds);
                 zoneHostIds.addAll(hostIds);
             }
             zoneHostIds.sort(Comparator.comparingLong(x -> x));
+            for (Long nonRoutingHostId : nonRoutingHostIds) {
+                setupMSList(nonRoutingHostId, zone.getId(), zoneHostIds, 
lbAlgorithm, globalLbCheckInterval);
+            }
             for (Long clusterId : clusterIds) {
-                final Long lbCheckInterval = 
getLBPreferredHostCheckInterval(clusterId);
+                final Long clusterLbCheckInterval = 
getLBPreferredHostCheckInterval(clusterId);
                 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);
                 }
             }
         }
     }
 
+    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);
+        if (answer == null || !answer.getResult()) {
+            logger.warn(String.format("Failed to setup management servers list 
to the agent of ID: %d", hostId));
+        }
+    }
+
     private void configureAlgorithmMap() {
         final List<org.apache.cloudstack.agent.lb.IndirectAgentLBAlgorithm> 
algorithms = new ArrayList<>();
         algorithms.add(new IndirectAgentLBStaticAlgorithm());

Reply via email to