You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/09/06 13:08:22 UTC

[GitHub] [cloudstack] weizhouapache commented on a change in pull request #4534: Migrate vm across clusters

weizhouapache commented on a change in pull request #4534:
URL: https://github.com/apache/cloudstack/pull/4534#discussion_r702888757



##########
File path: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
##########
@@ -1345,6 +1353,37 @@ private boolean doMaintain(final long hostId) {
         return true;
     }
 
+    private boolean isClusterWideMigrationPossible(Host host, List<VMInstanceVO> vms, List<HostVO> hosts) {
+        if (MIGRATE_VM_ACROSS_CLUSTERS.valueIn(host.getDataCenterId())) {
+            s_logger.info("Looking for hosts across different clusters in zone: " + host.getDataCenterId());
+            Long podId = null;
+            for (final VMInstanceVO vm : vms) {
+                if (VirtualMachine.systemVMs.contains(vm.getType())) {
+                    // SystemVMs can only be migrated to same pod
+                    podId = host.getPodId();
+                    break;
+                }
+            }
+            hosts.addAll(listAllUpAndEnabledHosts(Host.Type.Routing, null, podId, host.getDataCenterId()));
+            if (CollectionUtils.isEmpty(hosts)) {
+                s_logger.warn("Unable to find a host for vm migration in zone: " + host.getDataCenterId());
+                return false;
+            }
+            s_logger.info("Found hosts in the zone for vm migration: " + hosts);
+            // Don't migrate vm if it has volumes on cluster-wide pool
+            for (final VMInstanceVO vm : vms) {
+                if (! HypervisorType.VMware.equals(host.getHypervisorType()) && _vmMgr.checkIfVmHasClusterWideVolumes(vm.getId())) {
+                    s_logger.warn(String.format("VM %s cannot be migrated across cluster as it has volumes on cluster-wide pool", vm));
+                    return false;
+                }
+            }

Review comment:
       @shwstppr 
   moved the hypervisor type check.
   
   I have considered the order of checks. in my opinion, the checks of vm volumes have more db queries than listAllUpAndEnabledHosts so I put the check prior to volume pool check.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org