From c401ff913d93d3f9a52c7edb72eee4c9b6339c0a Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Fri, 24 Aug 2012 15:37:17 +0530 Subject: [PATCH] CS-16117 : Load Test - In a 5000 hosts/5000 vm setup ,~450 Vms failed to get deployed becasue of "com.cloud.exception.InsufficientServerCapacityException" even though we have hosts that have enough capacity to host the vms. Using VM host id from deployment planner passed to storage allocator instead of VMprofile parameter. In retry cases VMprofile parameter will have incorrect host id. Reviewed-by: Nitin --- server/src/com/cloud/storage/StorageManagerImpl.java | 12 ++++++------ .../allocator/AbstractStoragePoolAllocator.java | 4 ++-- .../storage/allocator/LocalStoragePoolAllocator.java | 4 ++-- .../storage/allocator/StoragePoolAllocator.java | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 323cf12e1b1..9d3ed13c827 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -448,13 +448,13 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag return false; } - protected StoragePoolVO findStoragePool(DiskProfile dskCh, final DataCenterVO dc, HostPodVO pod, Long clusterId, VMInstanceVO vm, final Set avoid) { + protected StoragePoolVO findStoragePool(DiskProfile dskCh, final DataCenterVO dc, HostPodVO pod, Long clusterId, Long hostId, VMInstanceVO vm, final Set avoid) { VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); Enumeration en = _storagePoolAllocators.enumeration(); while (en.hasMoreElements()) { final StoragePoolAllocator allocator = en.nextElement(); - final List poolList = allocator.allocateToPool(dskCh, profile, dc.getId(), pod.getId(), clusterId, avoid, 1); + final List poolList = allocator.allocateToPool(dskCh, profile, dc.getId(), pod.getId(), clusterId, hostId, avoid, 1); if (poolList != null && !poolList.isEmpty()) { return (StoragePoolVO) poolList.get(0); } @@ -562,7 +562,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag while ((pod = _resourceMgr.findPod(null, null, dc, account.getId(), podsToAvoid)) != null) { podsToAvoid.add(pod.first().getId()); // Determine what storage pool to store the volume in - while ((pool = findStoragePool(dskCh, dc, pod.first(), null, null, poolsToAvoid)) != null) { + while ((pool = findStoragePool(dskCh, dc, pod.first(), null, null, null, poolsToAvoid)) != null) { poolsToAvoid.add(pool); volumeFolder = pool.getPath(); if (s_logger.isDebugEnabled()) { @@ -732,7 +732,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag DiskProfile dskCh = createDiskCharacteristics(volume, template, dc, diskOffering); dskCh.setHyperType(vm.getHypervisorType()); // Find a suitable storage to create volume on - StoragePoolVO destPool = findStoragePool(dskCh, dc, pod, clusterId, vm, avoidPools); + StoragePoolVO destPool = findStoragePool(dskCh, dc, pod, clusterId, null, vm, avoidPools); // Copy the volume from secondary storage to the destination storage pool stateTransitTo(volume, Event.CopyRequested); @@ -809,7 +809,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag break; } - pool = findStoragePool(dskCh, dc, pod, clusterId, vm, avoidPools); + pool = findStoragePool(dskCh, dc, pod, clusterId, vm.getHostId(), vm, avoidPools); if (pool == null) { s_logger.warn("Unable to find storage poll when create volume " + volume.getName()); break; @@ -1681,7 +1681,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag dskCh.setHyperType(dataDiskHyperType); DataCenterVO destPoolDataCenter = _dcDao.findById(destPoolDcId); HostPodVO destPoolPod = _podDao.findById(destPoolPodId); - StoragePoolVO destPool = findStoragePool(dskCh, destPoolDataCenter, destPoolPod, destPoolClusterId, null, new HashSet()); + StoragePoolVO destPool = findStoragePool(dskCh, destPoolDataCenter, destPoolPod, destPoolClusterId, null, null, new HashSet()); String secondaryStorageURL = getSecondaryStorageURL(volume.getDataCenterId()); if (destPool == null) { diff --git a/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java b/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java index 292f3130b39..00354bb3001 100755 --- a/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java +++ b/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java @@ -250,14 +250,14 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement @Override - public List allocateToPool(DiskProfile dskCh, VirtualMachineProfile vmProfile, long dcId, long podId, Long clusterId, Set avoids, int returnUpTo) { + public List allocateToPool(DiskProfile dskCh, VirtualMachineProfile vmProfile, long dcId, long podId, Long clusterId, Long hostId, Set avoids, int returnUpTo) { ExcludeList avoid = new ExcludeList(); for(StoragePool pool : avoids){ avoid.addPool(pool.getId()); } - DataCenterDeployment plan = new DataCenterDeployment(dcId, podId, clusterId, null, null, null); + DataCenterDeployment plan = new DataCenterDeployment(dcId, podId, clusterId, hostId, null, null); return allocateToPool(dskCh, vmProfile, plan, avoid, returnUpTo); } diff --git a/server/src/com/cloud/storage/allocator/LocalStoragePoolAllocator.java b/server/src/com/cloud/storage/allocator/LocalStoragePoolAllocator.java index 93d93319449..736d63b8426 100644 --- a/server/src/com/cloud/storage/allocator/LocalStoragePoolAllocator.java +++ b/server/src/com/cloud/storage/allocator/LocalStoragePoolAllocator.java @@ -100,8 +100,8 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator { } // data disk and host identified from deploying vm (attach volume case) - if (dskCh.getType() == Volume.Type.DATADISK && vmProfile.getVirtualMachine() != null && vmProfile.getVirtualMachine().getHostId() != null) { - List hostPools = _poolHostDao.listByHostId(vmProfile.getVirtualMachine().getHostId()); + if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null) { + List hostPools = _poolHostDao.listByHostId(plan.getHostId()); for (StoragePoolHostVO hostPool: hostPools) { StoragePoolVO pool = _storagePoolDao.findById(hostPool.getPoolId()); if (pool != null && pool.isLocal()) { diff --git a/server/src/com/cloud/storage/allocator/StoragePoolAllocator.java b/server/src/com/cloud/storage/allocator/StoragePoolAllocator.java index 0939a93e673..b984bfacfdb 100644 --- a/server/src/com/cloud/storage/allocator/StoragePoolAllocator.java +++ b/server/src/com/cloud/storage/allocator/StoragePoolAllocator.java @@ -29,7 +29,7 @@ import com.cloud.vm.VirtualMachineProfile; public interface StoragePoolAllocator extends Adapter { //keeping since storageMgr is using this API for some existing functionalities - List allocateToPool(DiskProfile dskCh, VirtualMachineProfile vmProfile, long dcId, long podId, Long clusterId, Set avoids, int returnUpTo); + List allocateToPool(DiskProfile dskCh, VirtualMachineProfile vmProfile, long dcId, long podId, Long clusterId, Long hostId, Set avoids, int returnUpTo); String chooseStorageIp(VirtualMachine vm, Host host, Host storage);