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

pearl11594 pushed a commit to branch fix-allocator-logic
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 154743a1b4b141437d7a65250027b5c6c0cb777e
Author: Pearl Dsilva <[email protected]>
AuthorDate: Fri Mar 21 07:45:23 2025 -0400

    Fix issue with allocator not considering subsequent clusters
---
 .../com/cloud/agent/manager/allocator/impl/RandomAllocator.java    | 6 +++---
 .../com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java  | 7 +++----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git 
a/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
 
b/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
index 53e44ab5aab..4005249e648 100644
--- 
a/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
+++ 
b/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
@@ -94,15 +94,15 @@ public class RandomAllocator extends AdapterBase implements 
HostAllocator {
             return suitableHosts;
         }
         String offeringHostTag = offering.getHostTag();
+
         VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();
         String templateTag = template.getTemplateTag();
         String hostTag = null;
         if (ObjectUtils.anyNull(offeringHostTag, templateTag)) {
             hostTag = offeringHostTag;
-            hostTag = hostTag == null ? templateTag : String.format("%s, %s", 
hostTag, templateTag);
-            logger.debug(String.format("Looking for hosts in dc [%s], pod 
[%s], cluster [%s] and complying with host tag(s): [%s]", dcId, podId, 
clusterId, hostTag));
+            logger.debug("Looking for hosts in dc [{}], pod [{}], cluster [{}] 
and complying with host tag(s): [{}]", dcId, podId, clusterId, hostTag);
         } else {
-            logger.debug("Looking for hosts in dc: " + dcId + "  pod:" + podId 
+ "  cluster:" + clusterId);
+            logger.debug("Looking for hosts in dc: {} pod: {} cluster: {}", 
dcId , podId, clusterId);
         }
         if (hosts != null) {
             // retain all computing hosts, regardless of whether they support 
routing...it's random after all
diff --git 
a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
 
b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
index 4a5f80571ae..89857994b09 100644
--- 
a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
+++ 
b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
@@ -130,8 +130,8 @@ public class FirstFitAllocator extends AdapterBase 
implements HostAllocator {
             // FirstFitAllocator should be used for user VMs only since it 
won't care whether the host is capable of routing or not
             return new ArrayList<>();
         }
-
-        logger.debug("Looking for hosts in zone [{}], pod [{}], cluster [{}]", 
dcId, podId, clusterId);
+        String paramAsStringToLog = String.format("zone [%s], pod [%s], 
cluster [%s]", dcId, podId, clusterId);
+        logger.debug("Looking for hosts in {}", paramAsStringToLog);
 
         String hostTagOnOffering = offering.getHostTag();
         String hostTagOnTemplate = template.getTemplateTag();
@@ -203,8 +203,7 @@ public class FirstFitAllocator extends AdapterBase 
implements HostAllocator {
 
 
         if (clusterHosts.isEmpty()) {
-            logger.error("No suitable host found for vm [{}] with tags [{}].", 
vmProfile, hostTagOnOffering);
-            throw new CloudRuntimeException(String.format("No suitable host 
found for vm [%s].", vmProfile));
+            logger.warn("No suitable host found for VM [{}] with tags {} in 
{}.", vmProfile, hostTagOnOffering, paramAsStringToLog);
         }
         // add all hosts that we are not considering to the avoid list
         List<HostVO> allhostsInCluster = 
_hostDao.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId, null);

Reply via email to