Skip to content

Commit 4b432c8

Browse files
authored
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
1 parent ee32f4c commit 4b432c8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import javax.inject.Inject;
4545
import javax.naming.ConfigurationException;
4646

47+
import com.cloud.cpu.CPU;
4748
import org.apache.cloudstack.acl.ControlledEntity;
4849
import org.apache.cloudstack.acl.SecurityChecker;
4950
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
@@ -1612,6 +1613,14 @@ public Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Ho
16121613
logger.debug("Hosts having capacity and suitable for migration: {}", suitableHosts);
16131614
}
16141615

1616+
// Only list hosts of the same architecture as the source Host in a multi-arch zone
1617+
if (!suitableHosts.isEmpty()) {
1618+
List<CPU.CPUArch> clusterArchs = ApiDBUtils.listZoneClustersArchs(vm.getDataCenterId());
1619+
if (CollectionUtils.isNotEmpty(clusterArchs) && clusterArchs.size() > 1) {
1620+
suitableHosts = suitableHosts.stream().filter(h -> h.getArch() == srcHost.getArch()).collect(Collectors.toList());
1621+
}
1622+
}
1623+
16151624
return new Ternary<>(otherHosts, suitableHosts, requiresStorageMotion);
16161625
}
16171626

0 commit comments

Comments
 (0)