cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devd...@apache.org
Subject git commit: updated refs/heads/master to 450d890
Date Fri, 20 Jun 2014 11:14:43 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 918c32043 -> 450d89094


CLOUDSTACK-6830: Fixed during VM migration, volumes on zone wide primary store
requires storage migration resulting in failure of VM migration. This also improves
the hostsformigration api. Firstly we were trying to list all hosts and then
finding suitable storage pools for all volumes and then we were checking whether
vm migration requires storage migration to that host. Now the process is updated.
We are checking for only those volumes which are not in zone wide primary store.
We are verifying by comparing volumes->poolid->clusterid to host clusterid. If it
uses local or clusterids are different then verifying whether host has suitable
storage pools for the volume of the vm to be migrated too.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/450d8909
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/450d8909
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/450d8909

Branch: refs/heads/master
Commit: 450d89094285f2363302dccc7e805466b61af9e9
Parents: 918c320
Author: Anshul Gangwar <anshul.gangwar@citrix.com>
Authored: Fri Jun 20 14:32:05 2014 +0530
Committer: Devdeep Singh <devdeep@gmail.com>
Committed: Fri Jun 20 16:32:19 2014 +0530

----------------------------------------------------------------------
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 16 +++-
 .../com/cloud/server/ManagementServerImpl.java  | 89 +++++++-------------
 2 files changed, 42 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/450d8909/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index d0fcd4a..728f04c 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -41,6 +41,8 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
@@ -69,7 +71,6 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
-import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.Listener;
@@ -160,6 +161,7 @@ import com.cloud.resource.ResourceManager;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.DiskOfferingVO;
+import com.cloud.storage.ScopeType;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.Volume;
@@ -1827,8 +1829,16 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         }
 
         if (fromHost.getClusterId().longValue() != dest.getCluster().getId()) {
-            s_logger.info("Source and destination host are not in same cluster, unable to
migrate to host: " + dest.getHost().getId());
-            throw new CloudRuntimeException("Source and destination host are not in same
cluster, unable to migrate to host: " + dest.getHost().getId());
+            List<VolumeVO> volumes = _volsDao.findCreatedByInstance(vm.getId());
+            for (VolumeVO volume : volumes) {
+                if (!(_storagePoolDao.findById(volume.getPoolId())).getScope().equals(ScopeType.ZONE))
{
+                    s_logger.info("Source and destination host are not in same cluster and
all volumes are not on zone wide primary store, unable to migrate to host: "
+                            + dest.getHost().getId());
+                    throw new CloudRuntimeException(
+                            "Source and destination host are not in same cluster and all
volumes are not on zone wide primary store, unable to migrate to host: "
+                                    + dest.getHost().getId());
+                }
+            }
         }
 
         VirtualMachineGuru vmGuru = getVmGuru(vm);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/450d8909/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 790441b..fb214b7 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -20,7 +20,6 @@ import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
@@ -38,6 +37,9 @@ import javax.crypto.spec.SecretKeySpec;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.commons.codec.binary.Base64;
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.affinity.AffinityGroupProcessor;
 import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
@@ -507,8 +509,6 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.GetVncPortAnswer;
@@ -1171,29 +1171,28 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         List<HostVO> allHosts = null;
         Map<Host, Boolean> requiresStorageMotion = new HashMap<Host, Boolean>();
         DataCenterDeployment plan = null;
-        boolean zoneWideStoragePool = false;
+
         if (canMigrateWithStorage) {
-            allHostsPair = searchForServers(startIndex, pageSize, null, hostType, null, srcHost.getDataCenterId(),
null, null, null, null, null, null, srcHost.getHypervisorType(),
-                    srcHost.getHypervisorVersion());
+            allHostsPair = searchForServers(startIndex, pageSize, null, hostType, null, srcHost.getDataCenterId(),
null, null, null, null, null, null,
+                    srcHost.getHypervisorType(), srcHost.getHypervisorVersion());
             allHosts = allHostsPair.first();
             allHosts.remove(srcHost);
-
-            // Check if the host has storage pools for all the volumes of the vm to be migrated.
-            for (Iterator<HostVO> iterator = allHosts.iterator(); iterator.hasNext();)
{
-                Host host = iterator.next();
-                Map<Volume, List<StoragePool>> volumePools = findSuitablePoolsForVolumes(vmProfile,
host);
-                if (volumePools.isEmpty()) {
-                    iterator.remove();
-                } else {
-                    if (srcHost.getHypervisorType() == HypervisorType.VMware || srcHost.getHypervisorType()
== HypervisorType.KVM) {
-                        zoneWideStoragePool = checkForZoneWideStoragePool(volumePools);
-                    }
-                    if ((!host.getClusterId().equals(srcHost.getClusterId()) || usesLocal)
&& !zoneWideStoragePool) {
-                        requiresStorageMotion.put(host, true);
+            for (VolumeVO volume : volumes) {
+                Long volClusterId = _poolDao.findById(volume.getPoolId()).getClusterId();
+                // only check for volume which are not in zone wide primary store, as only
those may require storage motion
+                if (volClusterId != null) {
+                    for (Iterator<HostVO> iterator = allHosts.iterator(); iterator.hasNext();)
{
+                        Host host = iterator.next();
+                        if (!host.getClusterId().equals(volClusterId) || usesLocal) {
+                            if (hasSuitablePoolsForVolume(volume, host, vmProfile)) {
+                                requiresStorageMotion.put(host, true);
+                            } else {
+                                iterator.remove();
+                            }
+                        }
                     }
                 }
             }
-
             plan = new DataCenterDeployment(srcHost.getDataCenterId(), null, null, null,
null, null);
         } else {
             Long cluster = srcHost.getClusterId();
@@ -1244,50 +1243,20 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         return new Ternary<Pair<List<? extends Host>, Integer>, List<?
extends Host>, Map<Host, Boolean>>(otherHosts, suitableHosts, requiresStorageMotion);
     }
 
-    private boolean checkForZoneWideStoragePool(Map<Volume, List<StoragePool>>
volumePools) {
-        boolean zoneWideStoragePool = false;
-        Collection<List<StoragePool>> pools = volumePools.values();
-        List<StoragePool> aggregatePoolList = new ArrayList<StoragePool>();
-        for (Iterator<List<StoragePool>> volumePoolsIter = pools.iterator();
volumePoolsIter.hasNext();) {
-            aggregatePoolList.addAll(volumePoolsIter.next());
-        }
-        for (StoragePool pool : aggregatePoolList) {
-            if (null == pool.getClusterId()) {
-                zoneWideStoragePool = true;
-                break;
-            }
-        }
-        return zoneWideStoragePool;
-    }
-
-    private Map<Volume, List<StoragePool>> findSuitablePoolsForVolumes(VirtualMachineProfile
vmProfile, Host host) {
-        List<VolumeVO> volumes = _volumeDao.findCreatedByInstance(vmProfile.getId());
-        Map<Volume, List<StoragePool>> suitableVolumeStoragePools = new HashMap<Volume,
List<StoragePool>>();
-
-        // For each volume find list of suitable storage pools by calling the allocators
-        for (VolumeVO volume : volumes) {
-            DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
-            DiskProfile diskProfile = new DiskProfile(volume, diskOffering, vmProfile.getHypervisorType());
-            DataCenterDeployment plan = new DataCenterDeployment(host.getDataCenterId(),
host.getPodId(), host.getClusterId(), host.getId(), null, null);
-            ExcludeList avoid = new ExcludeList();
-
-            boolean foundPools = false;
-            for (StoragePoolAllocator allocator : _storagePoolAllocators) {
-                List<StoragePool> poolList = allocator.allocateToPool(diskProfile,
vmProfile, plan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL);
-                if (poolList != null && !poolList.isEmpty()) {
-                    suitableVolumeStoragePools.put(volume, poolList);
-                    foundPools = true;
-                    break;
-                }
-            }
+    private boolean hasSuitablePoolsForVolume(VolumeVO volume, Host host, VirtualMachineProfile
vmProfile) {
+        DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
+        DiskProfile diskProfile = new DiskProfile(volume, diskOffering, vmProfile.getHypervisorType());
+        DataCenterDeployment plan = new DataCenterDeployment(host.getDataCenterId(), host.getPodId(),
host.getClusterId(), host.getId(), null, null);
+        ExcludeList avoid = new ExcludeList();
 
-            if (!foundPools) {
-                suitableVolumeStoragePools.clear();
-                break;
+        for (StoragePoolAllocator allocator : _storagePoolAllocators) {
+            List<StoragePool> poolList = allocator.allocateToPool(diskProfile, vmProfile,
plan, avoid, 1);
+            if (poolList != null && !poolList.isEmpty()) {
+                return true;
             }
         }
 
-        return suitableVolumeStoragePools;
+        return false;
     }
 
     @Override


Mime
View raw message