You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/11/05 01:45:37 UTC

[1/3] git commit: updated refs/heads/master to 3cc8239

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 <pr...@cloud.com>
Authored: Fri Oct 25 16:34:51 2013 -0700
Committer: Prachi Damle <pr...@cloud.com>
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) {


[3/3] git commit: updated refs/heads/master to 3cc8239

Posted by pr...@apache.org.
CLOUDSTACK-4755: cloudstack 4.x does not allow memory upgrade

Changes:
- Set total capacity of a host if it has changed in the CapacityChecker thread
- Fix bug while setting the reserved/used cpu/mem capacity - only one of them used to get set


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

Branch: refs/heads/master
Commit: 3cc823903a0aa99b20a55b13e871d0ad8f6caf79
Parents: 863a84a
Author: Prachi Damle <pr...@cloud.com>
Authored: Mon Nov 4 16:37:55 2013 -0800
Committer: Prachi Damle <pr...@cloud.com>
Committed: Mon Nov 4 16:45:11 2013 -0800

----------------------------------------------------------------------
 .../com/cloud/capacity/CapacityManagerImpl.java | 64 ++++++++++++++------
 1 file changed, 44 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3cc82390/server/src/com/cloud/capacity/CapacityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java
index 72905a7..1c5f189 100755
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@ -599,34 +599,58 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
         CapacityVO memCap = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_MEMORY);
 
         if (cpuCap != null && memCap != null){
+
+            long hostTotalCpu = host.getCpus().longValue() * host.getSpeed().longValue();
+
+            if (cpuCap.getTotalCapacity() != hostTotalCpu) {
+                s_logger.debug("Calibrate total cpu for host: " + host.getId() + " old total CPU:"
+                        + cpuCap.getTotalCapacity() + " new total CPU:" + hostTotalCpu);
+                cpuCap.setTotalCapacity(hostTotalCpu);
+
+            }
+
         	if (cpuCap.getUsedCapacity() == usedCpu && cpuCap.getReservedCapacity() == reservedCpu) {
         		s_logger.debug("No need to calibrate cpu capacity, host:" + host.getId() + " usedCpu: " + cpuCap.getUsedCapacity()
         				+ " reservedCpu: " + cpuCap.getReservedCapacity());
-        	} else if (cpuCap.getReservedCapacity() != reservedCpu) {
-        		s_logger.debug("Calibrate reserved cpu for host: " + host.getId() + " old reservedCpu:" + cpuCap.getReservedCapacity()
-        				+ " new reservedCpu:" + reservedCpu);
-        		cpuCap.setReservedCapacity(reservedCpu);
-        	} else if (cpuCap.getUsedCapacity() != usedCpu) {
-        		s_logger.debug("Calibrate used cpu for host: " + host.getId() + " old usedCpu:" + cpuCap.getUsedCapacity() + " new usedCpu:"
-        				+ usedCpu);
-        		cpuCap.setUsedCapacity(usedCpu);
+            } else {
+                if (cpuCap.getReservedCapacity() != reservedCpu) {
+                    s_logger.debug("Calibrate reserved cpu for host: " + host.getId() + " old reservedCpu:"
+                            + cpuCap.getReservedCapacity() + " new reservedCpu:" + reservedCpu);
+                    cpuCap.setReservedCapacity(reservedCpu);
+                }
+                if (cpuCap.getUsedCapacity() != usedCpu) {
+                    s_logger.debug("Calibrate used cpu for host: " + host.getId() + " old usedCpu:"
+                            + cpuCap.getUsedCapacity() + " new usedCpu:" + usedCpu);
+                    cpuCap.setUsedCapacity(usedCpu);
+                }
         	}
 
+            if (memCap.getTotalCapacity() != host.getTotalMemory()) {
+                s_logger.debug("Calibrate total memory for host: " + host.getId() + " old total memory:"
+                        + memCap.getTotalCapacity() + " new total memory:" + host.getTotalMemory());
+                memCap.setTotalCapacity(host.getTotalMemory());
+
+            }
+
 	        if (memCap.getUsedCapacity() == usedMemory && memCap.getReservedCapacity() == reservedMemory) {
 	            s_logger.debug("No need to calibrate memory capacity, host:" + host.getId() + " usedMem: " + memCap.getUsedCapacity()
 	                    + " reservedMem: " + memCap.getReservedCapacity());
-	        } else if (memCap.getReservedCapacity() != reservedMemory) {
-	            s_logger.debug("Calibrate reserved memory for host: " + host.getId() + " old reservedMem:" + memCap.getReservedCapacity()
-	                    + " new reservedMem:" + reservedMemory);
-	            memCap.setReservedCapacity(reservedMemory);
-	        } else if (memCap.getUsedCapacity() != usedMemory) {
-	            /*
-	             * Didn't calibrate for used memory, because VMs can be in state(starting/migrating) that I don't know on which host they are
-	             * allocated
-	             */
-	            s_logger.debug("Calibrate used memory for host: " + host.getId() + " old usedMem: " + memCap.getUsedCapacity()
-	                    + " new usedMem: " + usedMemory);
-	            memCap.setUsedCapacity(usedMemory);
+            } else {
+                if (memCap.getReservedCapacity() != reservedMemory) {
+                    s_logger.debug("Calibrate reserved memory for host: " + host.getId() + " old reservedMem:"
+                            + memCap.getReservedCapacity() + " new reservedMem:" + reservedMemory);
+                    memCap.setReservedCapacity(reservedMemory);
+                }
+                if (memCap.getUsedCapacity() != usedMemory) {
+                    /*
+                     * Didn't calibrate for used memory, because VMs can be in
+                     * state(starting/migrating) that I don't know on which host
+                     * they are allocated
+                     */
+                    s_logger.debug("Calibrate used memory for host: " + host.getId() + " old usedMem: "
+                            + memCap.getUsedCapacity() + " new usedMem: " + usedMemory);
+                    memCap.setUsedCapacity(usedMemory);
+                }
 	        }
 
 	        try {


[2/3] git commit: updated refs/heads/master to 3cc8239

Posted by pr...@apache.org.
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:
	- Changes due to VirtualMachineProfile changes done in master


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

Branch: refs/heads/master
Commit: 863a84a15dca7889692323e9e024fc8cedc1dc2b
Parents: 4be7947
Author: Prachi Damle <pr...@cloud.com>
Authored: Fri Oct 25 16:40:01 2013 -0700
Committer: Prachi Damle <pr...@cloud.com>
Committed: Mon Nov 4 16:45:06 2013 -0800

----------------------------------------------------------------------
 server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/863a84a1/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 f268957..0886840 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -916,7 +916,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
     }
 
     private boolean canAvoidCluster(Cluster clusterVO, ExcludeList avoids, ExcludeList plannerAvoidOutput,
-            VirtualMachineProfile<? extends VirtualMachine> vmProfile) {
+            VirtualMachineProfile vmProfile) {
 
         ExcludeList allocatorAvoidOutput = new ExcludeList(avoids.getDataCentersToAvoid(), avoids.getPodsToAvoid(),
                 avoids.getClustersToAvoid(), avoids.getHostsToAvoid(), avoids.getPoolsToAvoid());
@@ -990,7 +990,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
         return false;
     }
 
-    private Pair<Boolean, Boolean> findVMStorageRequirements(VirtualMachineProfile<? extends VirtualMachine> vmProfile) {
+    private Pair<Boolean, Boolean> findVMStorageRequirements(VirtualMachineProfile vmProfile) {
 
         boolean requiresShared = false, requiresLocal = false;