Skip to content

Commit 62d4d47

Browse files
bernardodemarcodhslove
authored andcommitted
fix allocation of vmfs storage pools (apache#10201)
1 parent bb6f5fd commit 62d4d47

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,24 @@ public List<StoragePool> allocateToPool(DiskProfile dskCh, VirtualMachineProfile
124124
protected List<StoragePool> reorderPoolsByCapacity(DeploymentPlan plan, List<StoragePool> pools) {
125125
Long zoneId = plan.getDataCenterId();
126126
Long clusterId = plan.getClusterId();
127-
short capacityType;
128127

129128
if (CollectionUtils.isEmpty(pools)) {
130129
return null;
131130
}
132131

133-
if (pools.get(0).getPoolType().isShared()) {
132+
short capacityType = Capacity.CAPACITY_TYPE_LOCAL_STORAGE;
133+
String storageType = "local";
134+
StoragePool storagePool = pools.get(0);
135+
if (storagePool.isShared()) {
134136
capacityType = Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED;
135-
} else {
136-
capacityType = Capacity.CAPACITY_TYPE_LOCAL_STORAGE;
137+
storageType = "shared";
137138
}
138139

140+
s_logger.debug(String.format(
141+
"Filtering storage pools by capacity type [%s] as the first storage pool of the list, with name [%s] and ID [%s], is a [%s] storage.",
142+
capacityType, storagePool.getName(), storagePool.getUuid(), storageType
143+
));
144+
139145
List<Long> poolIdsByCapacity = capacityDao.orderHostsByFreeCapacity(zoneId, clusterId, capacityType);
140146

141147
logger.debug(String.format("List of pools in descending order of available capacity [%s].", poolIdsByCapacity));
@@ -221,6 +227,8 @@ public List<StoragePool> reorderPools(List<StoragePool> pools, VirtualMachinePro
221227
}
222228

223229
List<StoragePool> reorderStoragePoolsBasedOnAlgorithm(List<StoragePool> pools, DeploymentPlan plan, Account account) {
230+
s_logger.debug(String.format("Using allocation algorithm [%s] to reorder pools.", allocationAlgorithm));
231+
224232
if (allocationAlgorithm.equals("random") || allocationAlgorithm.equals("userconcentratedpod_random") || (account == null)) {
225233
reorderRandomPools(pools);
226234
} else if (StringUtils.equalsAny(allocationAlgorithm, "userdispersing", "firstfitleastconsumed")) {

0 commit comments

Comments
 (0)