Skip to content

Commit a80debb

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 7a39b0a commit a80debb

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
@@ -180,6 +180,12 @@ public void addPool(long poolId) {
180180
_poolIds.add(poolId);
181181
}
182182

183+
public void removePool(long poolId) {
184+
if (_poolIds != null) {
185+
_poolIds.remove(poolId);
186+
}
187+
}
188+
183189
public void addDataCenter(long dataCenterId) {
184190
if (_dcIds == null) {
185191
_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
@@ -79,14 +79,22 @@ protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmPr
7979
}
8080

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

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

92+
// make sure our matching pool was not in avoid set
93+
for (StoragePoolVO pool : pools) {
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+
9098
if (pools.size() == 0) {
9199
if (s_logger.isDebugEnabled()) {
92100
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
@@ -93,6 +93,12 @@ protected List<StoragePool> select(DiskProfile dskCh,
9393
avoid.addPool(pool.getId());
9494
}
9595

96+
// make sure our matching pool was not in avoid set
97+
for (StoragePoolVO pool : storagePoolsByHypervisor) {
98+
s_logger.debug("Removing pool " + pool + " from avoid set, must have been inserted when searching for another disk's tag");
99+
avoid.removePool(pool.getId());
100+
}
101+
96102
for (StoragePoolVO storage : storagePools) {
97103
if (suitablePools.size() == returnUpTo) {
98104
break;

0 commit comments

Comments
 (0)