cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject git commit: updated refs/heads/master to 90a15bf
Date Wed, 03 Jul 2013 13:14:43 GMT
Updated Branches:
  refs/heads/master 4e823e3a3 -> 90a15bfff


CLOUDSTACK-2107
If the scaling up fails on the host the vm is running on try to migrate it to other hosts
in the cluster and try scaling.
CLOUDSTACK-3349
For deciding the host in the cluster try the new deployment manager now
Signed off by : nitin mehta<nitin.mehta@citrix.com>


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

Branch: refs/heads/master
Commit: 90a15bfff678c4acf050eb49cef29e64b18aafcb
Parents: 4e823e3
Author: Nitin Mehta <nitin.mehta@citrix.com>
Authored: Wed Jul 3 18:38:07 2013 +0530
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Wed Jul 3 18:40:22 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/vm/UserVmManagerImpl.java  | 35 ++++++++++++--------
 .../src/com/cloud/vm/VirtualMachineManager.java |  3 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 25 ++++++--------
 .../cloud/vm/MockVirtualMachineManagerImpl.java |  3 +-
 .../cloud/vm/VirtualMachineManagerImplTest.java | 15 ++-------
 5 files changed, 39 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90a15bff/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index a59fa5b..caaf96c 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1180,28 +1180,34 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
         boolean success = false;
         if(vmInstance.getState().equals(State.Running)){
             int retry = _scaleRetry;
+            ExcludeList excludes = new ExcludeList();
             boolean enableDynamicallyScaleVm = Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(),
Config.ConfigurationParameterScope.zone.toString(), vmInstance.getDataCenterId()));
             if(!enableDynamicallyScaleVm){
                throw new PermissionDeniedException("Dynamically scaling virtual machines
is disabled for this zone, please contact your admin");
             }
 
-            // Increment CPU and Memory count accordingly.
-            if (newCpu > currentCpu) {
-                _resourceLimitMgr.incrementResourceCount(caller.getAccountId(), ResourceType.cpu,
new Long (newCpu - currentCpu));
-            }
-            if (newMemory > currentMemory) {
-                _resourceLimitMgr.incrementResourceCount(caller.getAccountId(), ResourceType.memory,
new Long (newMemory - currentMemory));
-            }
-
             while (retry-- != 0) { // It's != so that it can match -1.
                 try{
+                    boolean existingHostHasCapacity = false;
+
+                    // Increment CPU and Memory count accordingly.
+                    if (newCpu > currentCpu) {
+                        _resourceLimitMgr.incrementResourceCount(caller.getAccountId(), ResourceType.cpu,
new Long (newCpu - currentCpu));
+                    }
+                    if (newMemory > currentMemory) {
+                        _resourceLimitMgr.incrementResourceCount(caller.getAccountId(), ResourceType.memory,
new Long (newMemory - currentMemory));
+                    }
+
                     // #1 Check existing host has capacity
-                    boolean existingHostHasCapacity = _capacityMgr.checkIfHostHasCapacity(vmInstance.getHostId(),
newServiceOffering.getSpeed() - currentServiceOffering.getSpeed(),
-                            (newServiceOffering.getRamSize() - currentServiceOffering.getRamSize())
* 1024L * 1024L, false, ApiDBUtils.getCpuOverprovisioningFactor(), 1f, false); // TO DO fill
it with mem.
+                    if( !excludes.shouldAvoid(ApiDBUtils.findHostById(vmInstance.getHostId()))
){
+                        existingHostHasCapacity = _capacityMgr.checkIfHostHasCapacity(vmInstance.getHostId(),
newServiceOffering.getSpeed() - currentServiceOffering.getSpeed(),
+                                (newServiceOffering.getRamSize() - currentServiceOffering.getRamSize())
* 1024L * 1024L, false, ApiDBUtils.getCpuOverprovisioningFactor(), 1f, false); // TO DO fill
it with mem.
+                        excludes.addHost(vmInstance.getHostId());
+                    }
 
-                    // #2 migrate the vm if host doesn't have capacity
+                    // #2 migrate the vm if host doesn't have capacity or is in avoid set
                     if (!existingHostHasCapacity){
-                        vmInstance = _itMgr.findHostAndMigrate(vmInstance.getType(), vmInstance,
newServiceOfferingId);
+                        vmInstance = _itMgr.findHostAndMigrate(vmInstance.getType(), vmInstance,
newServiceOfferingId, excludes);
                     }
 
                     // #3 scale the vm now
@@ -1220,7 +1226,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
                     s_logger.warn("Received exception while scaling ",e);
                 } catch (ManagementServerException e) {
                     s_logger.warn("Received exception while scaling ",e);
-                }finally{
+                } catch (Exception e) {
+                    s_logger.warn("Received exception while scaling ",e);
+                }
+                finally{
                     if(!success){
                         _itMgr.upgradeVmDb(vmId, currentServiceOffering.getId()); // rollback
                         // Decrement CPU and Memory count accordingly.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90a15bff/server/src/com/cloud/vm/VirtualMachineManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManager.java b/server/src/com/cloud/vm/VirtualMachineManager.java
index ea9f7bb..6320956 100644
--- a/server/src/com/cloud/vm/VirtualMachineManager.java
+++ b/server/src/com/cloud/vm/VirtualMachineManager.java
@@ -20,6 +20,7 @@ import java.net.URI;
 import java.util.List;
 import java.util.Map;
 
+import com.cloud.deploy.DeploymentPlanner;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 
 import com.cloud.agent.api.to.NicTO;
@@ -194,7 +195,7 @@ public interface VirtualMachineManager extends Manager {
     VMInstanceVO reConfigureVm(VMInstanceVO vm, ServiceOffering newServiceOffering, boolean
sameHost)
             throws ResourceUnavailableException, ConcurrentOperationException;
 
-    VMInstanceVO findHostAndMigrate(VirtualMachine.Type vmType, VMInstanceVO vm, Long newSvcOfferingId)
throws InsufficientCapacityException,
+    VMInstanceVO findHostAndMigrate(VirtualMachine.Type vmType, VMInstanceVO vm, Long newSvcOfferingId,
DeploymentPlanner.ExcludeList excludeHostList) throws InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException,
             VirtualMachineMigrationException, ManagementServerException;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90a15bff/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 3bc0063..30ee2d7 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -3007,7 +3007,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
     }
 
     @Override
-    public VMInstanceVO findHostAndMigrate(VirtualMachine.Type vmType, VMInstanceVO vm, Long
newSvcOfferingId)
+    public VMInstanceVO findHostAndMigrate(VirtualMachine.Type vmType, VMInstanceVO vm, Long
newSvcOfferingId, ExcludeList excludes)
             throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException,
VirtualMachineMigrationException, ManagementServerException {
 
         VirtualMachineProfile<VMInstanceVO> profile = new VirtualMachineProfileImpl<VMInstanceVO>(vm);
@@ -3019,27 +3019,22 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         }
         Host host = _hostDao.findById(srcHostId);
         DataCenterDeployment plan = new DataCenterDeployment(host.getDataCenterId(), host.getPodId(),
host.getClusterId(), null, null, null);
-        ExcludeList excludes = new ExcludeList();
         excludes.addHost(vm.getHostId());
         vm.setServiceOfferingId(newSvcOfferingId); // Need to find the destination host based
on new svc offering
 
         DeployDestination dest = null;
 
-        for (DeploymentPlanner planner : _planners) {
-            if (planner.canHandle(profile, plan, excludes)) {
-                dest = planner.plan(profile, plan, excludes);
-            } else {
-                continue;
-            }
+        try {
+            dest = _dpMgr.planDeployment(profile, plan, excludes);
+        } catch (AffinityConflictException e2) {
+            s_logger.warn("Unable to create deployment, affinity rules associted to the VM
conflict", e2);
+            throw new CloudRuntimeException(
+                    "Unable to create deployment, affinity rules associted to the VM conflict");
+        }
 
-            if (dest != null) {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Planner " + planner + " found " + dest + " for scaling
the vm to.");
-                }
-                break;
-            }
+        if (dest != null) {
             if (s_logger.isDebugEnabled()) {
-                s_logger.debug("Planner " + planner + " was unable to find anything.");
+                s_logger.debug(" Found " + dest + " for scaling the vm to.");
             }
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90a15bff/server/test/com/cloud/vm/MockVirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/MockVirtualMachineManagerImpl.java b/server/test/com/cloud/vm/MockVirtualMachineManagerImpl.java
index 94ddea6..14ef48b 100755
--- a/server/test/com/cloud/vm/MockVirtualMachineManagerImpl.java
+++ b/server/test/com/cloud/vm/MockVirtualMachineManagerImpl.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import com.cloud.deploy.DeploymentPlanner;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.springframework.stereotype.Component;
 
@@ -281,7 +282,7 @@ public class MockVirtualMachineManagerImpl extends ManagerBase implements
Virtua
     }
 
     @Override
-    public VMInstanceVO findHostAndMigrate(VirtualMachine.Type vmType, VMInstanceVO vm, Long
newSvcOfferingId) throws InsufficientCapacityException,
+    public VMInstanceVO findHostAndMigrate(Type vmType, VMInstanceVO vm, Long newSvcOfferingId,
DeploymentPlanner.ExcludeList excludeHostList) throws InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException,
             VirtualMachineMigrationException, ManagementServerException{
         return null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90a15bff/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java b/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
index 1847a05..44e22e2 100644
--- a/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
+++ b/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
@@ -26,6 +26,7 @@ import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.deploy.DeployDestination;
+import com.cloud.deploy.DeploymentPlanner;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.server.ConfigurationServer;
@@ -45,9 +46,6 @@ import com.cloud.agent.api.MigrateWithStorageCompleteAnswer;
 import com.cloud.agent.api.MigrateWithStorageCompleteCommand;
 import com.cloud.agent.api.CheckVirtualMachineAnswer;
 import com.cloud.agent.api.CheckVirtualMachineCommand;
-import com.cloud.capacity.CapacityManager;
-import com.cloud.configuration.ConfigurationManager;
-import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.HostPodDao;
@@ -56,16 +54,12 @@ import com.cloud.exception.ManagementServerException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.exception.VirtualMachineMigrationException;
 import com.cloud.exception.OperationTimedoutException;
-import com.cloud.host.HostVO;
-import com.cloud.host.dao.HostDao;
 import com.cloud.hypervisor.HypervisorGuru;
 import com.cloud.hypervisor.HypervisorGuruManager;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.NetworkManager;
 import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.StoragePoolHostVO;
-import com.cloud.storage.VolumeManager;
-import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.StoragePoolHostDao;
 import com.cloud.storage.dao.VMTemplateDao;
@@ -77,10 +71,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.UserVmDetailsDao;
 import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
-import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd;
 import com.cloud.utils.Pair;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
 import com.cloud.vm.snapshot.VMSnapshotManager;
 import com.cloud.vm.VirtualMachine.Event;
@@ -97,7 +88,6 @@ import org.mockito.Spy;
 import static org.mockito.Matchers.anyLong;
 import static org.mockito.Mockito.*;
 
-import java.lang.reflect.Field;
 import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
@@ -281,7 +271,8 @@ public class VirtualMachineManagerImplTest {
 
         when(_vmInstance.getHostId()).thenReturn(null);
         when(_vmInstanceDao.findById(anyLong())).thenReturn(_vmInstance);
-        _vmMgr.findHostAndMigrate(VirtualMachine.Type.User, _vmInstance, 2l);
+        DeploymentPlanner.ExcludeList excludeHostList = new DeploymentPlanner.ExcludeList();
+        _vmMgr.findHostAndMigrate(VirtualMachine.Type.User, _vmInstance, 2l, excludeHostList);
 
     }
 


Mime
View raw message