Updated Branches:
refs/heads/master 57678257a -> 3cc823903
CLOUDSTACK-4948: DeploymentPlanner: Logic to check if cluster can be avoided,
needs to consider if VM is using local storage and/or shared storage
Changes:
- Consider if VM requires the local storage or shared storage or both for its
disks.
- Accordingly all pools in the cluster should consider local or shared or both
pools
Conflicts:
server/src/com/cloud/agent/manager/allocator/HostAllocator.java
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4be79472
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4be79472
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4be79472
Branch: refs/heads/master
Commit: 4be79472819d6100579a44fee71253ab54766713
Parents: 5767825
Author: Prachi Damle <[email protected]>
Authored: Fri Oct 25 16:34:51 2013 -0700
Committer: Prachi Damle <[email protected]>
Committed: Mon Nov 4 16:45:02 2013 -0800
----------------------------------------------------------------------
.../agent/manager/allocator/HostAllocator.java | 68 +++++++++++++-------
.../api/storage/StoragePoolAllocator.java | 5 ++
.../deploy/DeploymentPlanningManagerImpl.java | 68 +++++++++++++++-----
3 files changed, 103 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be79472/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
b/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
index 14525aa..f21455e 100755
--- a/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
+++ b/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
@@ -38,7 +38,7 @@ public interface HostAllocator extends Adapter {
/**
* Determines which physical hosts are suitable to
* allocate the guest virtual machines on
- *
+ *
* @param VirtualMachineProfile vmProfile
* @param DeploymentPlan plan
* @param GuestType type
@@ -46,35 +46,57 @@ public interface HostAllocator extends Adapter {
* @param int returnUpTo (use -1 to return all possible hosts)
* @return List<Host> List of hosts that are suitable for VM allocation
**/
-
+
public List<Host> allocateTo(VirtualMachineProfile vmProfile,
DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo);
-
+
/**
- * Determines which physical hosts are suitable to
- * allocate the guest virtual machines on
- *
- * @param VirtualMachineProfile vmProfile
- * @param DeploymentPlan plan
- * @param GuestType type
- * @param ExcludeList avoid
- * @param int returnUpTo (use -1 to return all possible hosts)
- * @param boolean considerReservedCapacity (default should be true, set to
false if host capacity calculation should not look at reserved capacity)
- * @return List<Host> List of hosts that are suitable for VM allocation
- **/
-
+ * Determines which physical hosts are suitable to allocate the guest
+ * virtual machines on
+ *
+ * Allocators must set any other hosts not considered for allocation in the
+ * ExcludeList avoid. Thus the avoid set and the list of hosts suitable,
+ * together must cover the entire host set in the cluster.
+ *
+ * @param VirtualMachineProfile
+ * vmProfile
+ * @param DeploymentPlan
+ * plan
+ * @param GuestType
+ * type
+ * @param ExcludeList
+ * avoid
+ * @param int returnUpTo (use -1 to return all possible hosts)
+ * @param boolean considerReservedCapacity (default should be true, set to
+ * false if host capacity calculation should not look at reserved
+ * capacity)
+ * @return List<Host> List of hosts that are suitable for VM allocation
+ **/
+
public List<Host> allocateTo(VirtualMachineProfile vmProfile,
DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean
considerReservedCapacity);
/**
- * Determines which physical hosts are suitable to
- * allocate the guest virtual machines on
+ * Determines which physical hosts are suitable to allocate the guest
+ * virtual machines on
*
- * @param VirtualMachineProfile vmProfile
- * @param DeploymentPlan plan
- * @param GuestType type
- * @param ExcludeList avoid
- * @param List<HostVO> hosts
+ * Allocators must set any other hosts not considered for allocation in the
+ * ExcludeList avoid. Thus the avoid set and the list of hosts suitable,
+ * together must cover the entire host set in the cluster.
+ *
+ *
+ * @param VirtualMachineProfile
+ * vmProfile
+ * @param DeploymentPlan
+ * plan
+ * @param GuestType
+ * type
+ * @param ExcludeList
+ * avoid
+ * @param List
+ * <HostVO> hosts
* @param int returnUpTo (use -1 to return all possible hosts)
- * @param boolean considerReservedCapacity (default should be true, set to
false if host capacity calculation should not look at reserved capacity)
+ * @param boolean considerReservedCapacity (default should be true, set to
+ * false if host capacity calculation should not look at reserved
+ * capacity)
* @return List<Host> List of hosts that are suitable for VM allocation
**/
public List<Host> allocateTo(VirtualMachineProfile vmProfile,
DeploymentPlan plan, Type type, ExcludeList avoid, List<? extends Host> hosts,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be79472/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StoragePoolAllocator.java
----------------------------------------------------------------------
diff --git
a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StoragePoolAllocator.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StoragePoolAllocator.java
index 54808c1..e8ade44 100644
---
a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StoragePoolAllocator.java
+++
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StoragePoolAllocator.java
@@ -30,6 +30,11 @@ import com.cloud.vm.VirtualMachineProfile;
public interface StoragePoolAllocator extends Adapter {
/**
* Determines which storage pools are suitable for the guest virtual
machine
+ * and returns a list of pools suitable.
+ *
+ * Allocators must set any other pools not considered for allocation in the
+ * ExcludeList avoid. Thus the avoid set and the list of pools suitable,
+ * together must cover the entire pool set in the cluster.
*
* @param DiskProfile
* dskCh
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be79472/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 e79e8e3..f268957 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -864,6 +864,7 @@ public class DeploymentPlanningManagerImpl extends
ManagerBase implements Deploy
DataCenterDeployment potentialPlan = new
DataCenterDeployment(plan.getDataCenterId(), clusterVO.getPodId(),
clusterVO.getId(), null, plan.getPoolId(), null,
plan.getReservationContext());
+
// find suitable hosts under this cluster, need as many hosts as we
// get.
List<Host> suitableHosts = findSuitableHosts(vmProfile,
potentialPlan, avoid, HostAllocator.RETURN_UPTO_ALL);
@@ -906,7 +907,7 @@ public class DeploymentPlanningManagerImpl extends
ManagerBase implements Deploy
s_logger.debug("No suitable hosts found under this Cluster: "
+ clusterId);
}
- if (canAvoidCluster(clusterVO, avoid, PlannerAvoidOutput)) {
+ if (canAvoidCluster(clusterVO, avoid, PlannerAvoidOutput,
vmProfile)) {
avoid.addCluster(clusterVO.getId());
}
}
@@ -914,7 +915,8 @@ public class DeploymentPlanningManagerImpl extends
ManagerBase implements Deploy
return null;
}
- private boolean canAvoidCluster(Cluster clusterVO, ExcludeList avoids,
ExcludeList plannerAvoidOutput) {
+ private boolean canAvoidCluster(Cluster clusterVO, ExcludeList avoids,
ExcludeList plannerAvoidOutput,
+ VirtualMachineProfile<? extends VirtualMachine> vmProfile) {
ExcludeList allocatorAvoidOutput = new
ExcludeList(avoids.getDataCentersToAvoid(), avoids.getPodsToAvoid(),
avoids.getClustersToAvoid(), avoids.getHostsToAvoid(),
avoids.getPoolsToAvoid());
@@ -938,28 +940,43 @@ public class DeploymentPlanningManagerImpl extends
ManagerBase implements Deploy
}
}
+ // all hosts in avoid set, avoid the cluster. Otherwise check the pools
+ if (avoidAllHosts) {
+ return true;
+ }
+
// 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.
+ // or pools not suitable for the allocators to handle or there is no
+ // linkage of any suitable host to any of the pools in cluster
// 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;
+
+ Pair<Boolean, Boolean> storageRequirements =
findVMStorageRequirements(vmProfile);
+ boolean vmRequiresSharedStorage = storageRequirements.first();
+ boolean vmRequiresLocalStorege = storageRequirements.second();
+
+ if (vmRequiresSharedStorage) {
+ // 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) {
+
+ if (vmRequiresLocalStorege) {
// check local pools
- List<StoragePoolVO> allLocalPoolsInCluster =
_storagePoolDao.findLocalStoragePoolsByTags(clusterVO.getDataCenterId(),
- clusterVO.getPodId(), clusterVO.getId(), null);
+ 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
+ // there's some pool in the cluster that is not yet
+ // in avoid set
avoidAllPools = false;
break;
}
@@ -973,6 +990,27 @@ public class DeploymentPlanningManagerImpl extends
ManagerBase implements Deploy
return false;
}
+ private Pair<Boolean, Boolean>
findVMStorageRequirements(VirtualMachineProfile<? extends VirtualMachine>
vmProfile) {
+
+ boolean requiresShared = false, requiresLocal = false;
+
+ List<VolumeVO> volumesTobeCreated =
_volsDao.findUsableVolumesForInstance(vmProfile.getId());
+
+ // for each volume find whether shared or local pool is required
+ for (VolumeVO toBeCreated : volumesTobeCreated) {
+ DiskOfferingVO diskOffering =
_diskOfferingDao.findById(toBeCreated.getDiskOfferingId());
+
+ if (diskOffering != null) {
+ if (diskOffering.getUseLocalStorage()) {
+ requiresLocal = true;
+ } else {
+ requiresShared = true;
+ }
+ }
+ }
+
+ return new Pair<Boolean, Boolean>(requiresShared, requiresLocal);
+ }
protected Pair<Host, Map<Volume, StoragePool>>
findPotentialDeploymentResources(List<Host> suitableHosts,
Map<Volume, List<StoragePool>> suitableVolumeStoragePools,
ExcludeList avoid,
DeploymentPlanner.PlannerResourceUsage resourceUsageRequired) {