Skip to content

Commit beb0725

Browse files
Pearl1594dhslove
authored andcommitted
List only those hosts matching source host arch in multi-arch zones (apache#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 ac3c61d commit beb0725

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;
@@ -1654,6 +1655,14 @@ public Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Ho
16541655
logger.debug("Hosts having capacity and suitable for migration: {}", suitableHosts);
16551656
}
16561657

1658+
// Only list hosts of the same architecture as the source Host in a multi-arch zone
1659+
if (!suitableHosts.isEmpty()) {
1660+
List<CPU.CPUArch> clusterArchs = ApiDBUtils.listZoneClustersArchs(vm.getDataCenterId());
1661+
if (CollectionUtils.isNotEmpty(clusterArchs) && clusterArchs.size() > 1) {
1662+
suitableHosts = suitableHosts.stream().filter(h -> h.getArch() == srcHost.getArch()).collect(Collectors.toList());
1663+
}
1664+
}
1665+
16571666
return new Ternary<>(otherHosts, suitableHosts, requiresStorageMotion);
16581667
}
16591668

0 commit comments

Comments
 (0)