Skip to content

Commit fc08283

Browse files
author
Marcus Sorensen
committed
CLOUDSTACK-5853
Create two storage pools, one with storage tag X, one with storage tag Y. Create a service offering with storage tag X. Create a disk offering with storage tag Y. Attempt to deploy a virtual machine with a datadisk, using given offerings, it fails. Deployment planner keeps a global object 'avoid'. It loops through each volume to be created, asking storage allocators for matching pools, passing this avoid object. First disk matches a pool or pools, adds ALL other pools to avoid object, then deployment planner attaches matching pools to a list for that disk. Second disk matches a pool, adds all other pools to avoid object, then deployment planner says "wait, matching pool is in avoid, can't use it". Oops. In fact, at this point ALL pools are in avoid (unless there are other pools that have both tags). Need to remove matching pool from the avoid set during each select phase.
1 parent 6fdebe5 commit fc08283

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

api/src/com/cloud/deploy/DeploymentPlanner.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ public void addPool(long poolId) {
176176
_poolIds.add(poolId);
177177
}
178178

179+
public void removePool(long poolId) {
180+
if (_poolIds != null) {
181+
_poolIds.remove(poolId);
182+
}
183+
}
184+
179185
public void addDataCenter(long dataCenterId) {
180186
if (_dcIds == null) {
181187
_dcIds = new HashSet<Long>();

engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,22 @@ protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmPr
7777
}
7878

7979
List<StoragePoolVO> pools = _storagePoolDao.findPoolsByTags(dcId, podId, clusterId, dskCh.getTags());
80+
s_logger.debug("Found pools matching tags: " + pools);
8081

8182
// add remaining pools in cluster, that did not match tags, to avoid set
8283
List<StoragePoolVO> allPools = _storagePoolDao.findPoolsByTags(dcId, podId, clusterId, null);
8384
allPools.removeAll(pools);
8485
for (StoragePoolVO pool : allPools) {
86+
s_logger.debug("Adding pool " + pool + " to avoid set since it did not match tags");
8587
avoid.addPool(pool.getId());
8688
}
8789

90+
// make sure our matching pool was not in avoid set
91+
for (StoragePoolVO pool : pools) {
92+
s_logger.debug("Removing pool " + pool + " from avoid set, must have been inserted when searching for another disk's tag");
93+
avoid.removePool(pool.getId());
94+
}
95+
8896
if (pools.size() == 0) {
8997
if (s_logger.isDebugEnabled()) {
9098
s_logger.debug("No storage pools available for " + ServiceOffering.StorageType.shared.toString() + " volume allocation, returning");

engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmPr
8989
avoid.addPool(pool.getId());
9090
}
9191

92+
// make sure our matching pool was not in avoid set
93+
for (StoragePoolVO pool : storagePoolsByHypervisor) {
94+
s_logger.debug("Removing pool " + pool + " from avoid set, must have been inserted when searching for another disk's tag");
95+
avoid.removePool(pool.getId());
96+
}
97+
9298
for (StoragePoolVO storage : storagePools) {
9399
if (suitablePools.size() == returnUpTo) {
94100
break;

0 commit comments

Comments
 (0)