From 4b432c82ca00fa1bd9198de82434d1e6d9fcd321 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 19 Feb 2025 08:43:41 -0500 Subject: [PATCH] List only those hosts matching source host arch in multi-arch zones (#10369) * List only those hosts matching source host arch in multi-arch zones * remove duplicate import due to merge conflict * filter only if suitable hosts aren't empty * get cpu archs only if there are suitable hosts --- .../main/java/com/cloud/server/ManagementServerImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java b/server/src/main/java/com/cloud/server/ManagementServerImpl.java index 9ffad8b8418..8575a26a5cb 100644 --- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java +++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java @@ -44,6 +44,7 @@ import javax.crypto.spec.SecretKeySpec; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.cloud.cpu.CPU; import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.SecurityChecker; import org.apache.cloudstack.affinity.AffinityGroupProcessor; @@ -1612,6 +1613,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe logger.debug("Hosts having capacity and suitable for migration: {}", suitableHosts); } + // Only list hosts of the same architecture as the source Host in a multi-arch zone + if (!suitableHosts.isEmpty()) { + List clusterArchs = ApiDBUtils.listZoneClustersArchs(vm.getDataCenterId()); + if (CollectionUtils.isNotEmpty(clusterArchs) && clusterArchs.size() > 1) { + suitableHosts = suitableHosts.stream().filter(h -> h.getArch() == srcHost.getArch()).collect(Collectors.toList()); + } + } + return new Ternary<>(otherHosts, suitableHosts, requiresStorageMotion); }