cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject git commit: updated refs/heads/4.2 to 624b324
Date Fri, 18 Oct 2013 11:10:58 GMT
Updated Branches:
  refs/heads/4.2 51a4d2677 -> 624b324cc


CLOUDSTACK-4681: data disk with local disk offering are geting created on shared storage
The cluster and zone wide storage pool allocators returned shared pools even for volumes meant
to be on local storage pool.
If the VM uses local disk then cluster and zone storage allocators should not handle it and
return null or empty list.

Also fixed the deployment planner to avoid a cluster if
a. avoid set returned by storage pool allocators is empty OR
b. all local or shared pools in a cluster are in avoid state


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

Branch: refs/heads/4.2
Commit: 624b324cc1299f93ca2aaf08f8d6484cf39adaa3
Parents: 51a4d26
Author: Koushik Das <koushik@apache.org>
Authored: Fri Oct 18 16:34:47 2013 +0530
Committer: Koushik Das <koushik@apache.org>
Committed: Fri Oct 18 16:34:47 2013 +0530

----------------------------------------------------------------------
 .../ClusterScopeStoragePoolAllocator.java       | 19 ++++++-----
 .../allocator/LocalStoragePoolAllocator.java    | 19 ++++++-----
 .../allocator/ZoneWideStoragePoolAllocator.java | 30 +++++++++---------
 .../deploy/DeploymentPlanningManagerImpl.java   | 33 ++++++++++++++++----
 4 files changed, 63 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/624b324c/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java
b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java
index a026290..66d5505 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java
@@ -51,8 +51,13 @@ public class ClusterScopeStoragePoolAllocator extends AbstractStoragePoolAllocat
     @Override
     protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile<?
extends VirtualMachine> vmProfile,
             DeploymentPlan plan, ExcludeList avoid, int returnUpTo) {
-
         s_logger.debug("ClusterScopeStoragePoolAllocator looking for storage pool");
+
+        if (dskCh.useLocalStorage()) {
+            // cluster wide allocator should bail out in case of local disk
+            return null;
+        }
+
         List<StoragePool> suitablePools = new ArrayList<StoragePool>();
 
         long dcId = plan.getDataCenterId();
@@ -84,9 +89,7 @@ public class ClusterScopeStoragePoolAllocator extends AbstractStoragePoolAllocat
 
         if (pools.size() == 0) {
             if (s_logger.isDebugEnabled()) {
-                String storageType = dskCh.useLocalStorage() ? ServiceOffering.StorageType.local.toString()
-                        : ServiceOffering.StorageType.shared.toString();
-                s_logger.debug("No storage pools available for " + storageType + " volume
allocation, returning");
+                s_logger.debug("No storage pools available for " + ServiceOffering.StorageType.shared.toString()
+ " volume allocation, returning");
             }
             return suitablePools;
         }
@@ -95,16 +98,16 @@ public class ClusterScopeStoragePoolAllocator extends AbstractStoragePoolAllocat
             if (suitablePools.size() == returnUpTo) {
                 break;
             }
-            StoragePool pol = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
-            if (filter(avoid, pol, dskCh, plan)) {
-                suitablePools.add(pol);
+            StoragePool storagePool = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
+            if (filter(avoid, storagePool, dskCh, plan)) {
+                suitablePools.add(storagePool);
             } else {
                 avoid.addPool(pool.getId());
             }
         }
 
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("FirstFitStoragePoolAllocator returning " + suitablePools.size()
+ " suitable storage pools");
+            s_logger.debug("ClusterScopeStoragePoolAllocator returning " + suitablePools.size()
+ " suitable storage pools");
         }
 
         return suitablePools;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/624b324c/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
index 58f3c7f..3bc17ea 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/LocalStoragePoolAllocator.java
@@ -67,25 +67,24 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator
{
     @Override
     protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile<?
extends VirtualMachine> vmProfile,
             DeploymentPlan plan, ExcludeList avoid, int returnUpTo) {
-
-        List<StoragePool> suitablePools = new ArrayList<StoragePool>();
-
         s_logger.debug("LocalStoragePoolAllocator trying to find storage pool to fit the
vm");
 
         if (!dskCh.useLocalStorage()) {
-            return suitablePools;
+            return null;
         }
 
+        List<StoragePool> suitablePools = new ArrayList<StoragePool>();
+
         // data disk and host identified from deploying vm (attach volume case)
         if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null)
{
             List<StoragePoolHostVO> hostPools = _poolHostDao.listByHostId(plan.getHostId());
             for (StoragePoolHostVO hostPool : hostPools) {
                 StoragePoolVO pool = _storagePoolDao.findById(hostPool.getPoolId());
                 if (pool != null && pool.isLocal()) {
-                    StoragePool pol = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
-                    if (filter(avoid, pol, dskCh, plan)) {
+                    StoragePool storagePool = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
+                    if (filter(avoid, storagePool, dskCh, plan)) {
                         s_logger.debug("Found suitable local storage pool " + pool.getId()
+ ", adding to list");
-                        suitablePools.add(pol);
+                        suitablePools.add(storagePool);
                     } else {
                         avoid.addPool(pool.getId());
                     }
@@ -106,9 +105,9 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator
{
                 if (suitablePools.size() == returnUpTo) {
                     break;
                 }
-                StoragePool pol = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
-                if (filter(avoid, pol, dskCh, plan)) {
-                    suitablePools.add(pol);
+                StoragePool storagePool = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
+                if (filter(avoid, storagePool, dskCh, plan)) {
+                    suitablePools.add(storagePool);
                 } else {
                     avoid.addPool(pool.getId());
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/624b324c/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java
b/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java
index f1723c0..db604c7 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java
@@ -57,21 +57,24 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator
{
                storageMgr.storagePoolHasEnoughSpace(requestVolumes, pool);
     }
 
-	@Override
-	protected List<StoragePool> select(DiskProfile dskCh,
-			VirtualMachineProfile<? extends VirtualMachine> vmProfile,
-			DeploymentPlan plan, ExcludeList avoid, int returnUpTo) {
-	    s_logger.debug("ZoneWideStoragePoolAllocator to find storage pool");
-		List<StoragePool> suitablePools = new ArrayList<StoragePool>();
+    @Override
+    protected List<StoragePool> select(DiskProfile dskCh,
+            VirtualMachineProfile<? extends VirtualMachine> vmProfile,
+            DeploymentPlan plan, ExcludeList avoid, int returnUpTo) {
+        s_logger.debug("ZoneWideStoragePoolAllocator to find storage pool");
 
-        List<StoragePoolVO> storagePools = _storagePoolDao.findZoneWideStoragePoolsByTags(plan.getDataCenterId(),
dskCh.getTags());
+        if (dskCh.useLocalStorage()) {
+            return null;
+        }
 
+        List<StoragePool> suitablePools = new ArrayList<StoragePool>();
+
+        List<StoragePoolVO> storagePools = _storagePoolDao.findZoneWideStoragePoolsByTags(plan.getDataCenterId(),
dskCh.getTags());
         if (storagePools == null) {
             storagePools = new ArrayList<StoragePoolVO>();
         }
 
         List<StoragePoolVO> anyHypervisorStoragePools = new ArrayList<StoragePoolVO>();
-
         for (StoragePoolVO storagePool : storagePools) {
             if (HypervisorType.Any.equals(storagePool.getHypervisor())) {
                 anyHypervisorStoragePools.add(storagePool);
@@ -79,9 +82,7 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator
{
         }
 
         List<StoragePoolVO> storagePoolsByHypervisor = _storagePoolDao.findZoneWideStoragePoolsByHypervisor(plan.getDataCenterId(),
dskCh.getHypervisorType());
-
         storagePools.retainAll(storagePoolsByHypervisor);
-
         storagePools.addAll(anyHypervisorStoragePools);
 
         // add remaining pools in zone, that did not match tags, to avoid set
@@ -95,15 +96,16 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator
{
             if (suitablePools.size() == returnUpTo) {
                 break;
             }
-            StoragePool pol = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(storage.getId());
-            if (filter(avoid, pol, dskCh, plan)) {
-                suitablePools.add(pol);
+            StoragePool storagePool = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(storage.getId());
+            if (filter(avoid, storagePool, dskCh, plan)) {
+                suitablePools.add(storagePool);
             } else {
-                avoid.addPool(pol.getId());
+                avoid.addPool(storagePool.getId());
             }
         }
         return suitablePools;
     }
+
     @Override
     protected List<StoragePool> reorderPoolsByNumberOfVolumes(DeploymentPlan plan,
List<StoragePool> pools,
                                                               Account account) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/624b324c/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
index 6d36a07..23622dc 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -932,15 +932,36 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
             if (!allocatorAvoidOutput.shouldAvoid(host)) {
                 // there's some host in the cluster that is not yet in avoid set
                 avoidAllHosts = false;
+                break;
             }
         }
 
-        List<StoragePoolVO> allPoolsInCluster = _storagePoolDao.findPoolsByTags(clusterVO.getDataCenterId(),
-                clusterVO.getPodId(), clusterVO.getId(), null);
-        for (StoragePoolVO pool : allPoolsInCluster) {
-            if (!allocatorAvoidOutput.shouldAvoid(pool)) {
-                // there's some pool in the cluster that is not yet in avoid set
-                avoidAllPools = false;
+        // Cluster can be put in avoid set in following scenarios:
+        // 1. If storage allocators haven't put any pools in avoid set means either no pools
in cluster 
+        // or pools not suitable for the allocators to handle.
+        // 2. If all 'shared' or 'local' pools are in avoid set
+        if  (allocatorAvoidOutput.getPoolsToAvoid() != null && !allocatorAvoidOutput.getPoolsToAvoid().isEmpty())
{
+            // check shared pools
+            List<StoragePoolVO> allPoolsInCluster = _storagePoolDao.findPoolsByTags(clusterVO.getDataCenterId(),
+                    clusterVO.getPodId(), clusterVO.getId(), null);
+            for (StoragePoolVO pool : allPoolsInCluster) {
+                if (!allocatorAvoidOutput.shouldAvoid(pool)) {
+                    // there's some pool in the cluster that is not yet in avoid set
+                    avoidAllPools = false;
+                    break;
+                }
+            }
+            if (avoidAllPools) {
+                // check local pools
+                List<StoragePoolVO> allLocalPoolsInCluster = _storagePoolDao.findLocalStoragePoolsByTags(clusterVO.getDataCenterId(),
+                        clusterVO.getPodId(), clusterVO.getId(), null);
+                for (StoragePoolVO pool : allLocalPoolsInCluster) {
+                    if (!allocatorAvoidOutput.shouldAvoid(pool)) {
+                        // there's some pool in the cluster that is not yet in avoid set
+                        avoidAllPools = false;
+                        break;
+                    }
+                }
             }
         }
 


Mime
View raw message