Skip to content

Commit 1bda234

Browse files
SadiJrSadiJr
andauthored
Improve logs when searching one storage pool to allocate a new volume (#7212)
Co-authored-by: SadiJr <sadi@scclouds.com.br>
1 parent 2b35a02 commit 1bda234

5 files changed

Lines changed: 31 additions & 16 deletions

File tree

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,9 @@ private List<StoragePool> reorderPoolsByDiskProvisioningType(List<StoragePool> p
263263
}
264264

265265
protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh, DeploymentPlan plan) {
266-
if (s_logger.isDebugEnabled()) {
267-
s_logger.debug("Checking if storage pool is suitable, name: " + pool.getName() + " ,poolId: " + pool.getId());
268-
}
266+
s_logger.debug(String.format("Checking if storage pool [%s] is suitable to disk [%s].", pool, dskCh));
269267
if (avoid.shouldAvoid(pool)) {
270-
if (s_logger.isDebugEnabled()) {
271-
s_logger.debug("StoragePool is in avoid set, skipping this pool");
272-
}
268+
s_logger.debug(String.format("StoragePool [%s] is in avoid set, skipping this pool to allocation of disk [%s].", pool, dskCh));
273269
return false;
274270
}
275271

@@ -297,6 +293,8 @@ protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
297293
}
298294

299295
if (!checkDiskProvisioningSupport(dskCh, pool)) {
296+
s_logger.debug(String.format("Storage pool [%s] does not have support to disk provisioning of disk [%s].", pool, ReflectionToStringBuilderUtils.reflectOnlySelectedFields(dskCh,
297+
"type", "name", "diskOfferingId", "templateId", "volumeId", "provisioningType", "hyperType")));
300298
return false;
301299
}
302300

@@ -306,32 +304,35 @@ protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
306304

307305
Volume volume = volumeDao.findById(dskCh.getVolumeId());
308306
if(!storageMgr.storagePoolCompatibleWithVolumePool(pool, volume)) {
307+
s_logger.debug(String.format("Pool [%s] is not compatible with volume [%s], skipping it.", pool, volume));
309308
return false;
310309
}
311310

312311
if (pool.isManaged() && !storageUtil.managedStoragePoolCanScale(pool, plan.getClusterId(), plan.getHostId())) {
312+
s_logger.debug(String.format("Cannot allocate pool [%s] to volume [%s] because the max number of managed clustered filesystems has been exceeded.", pool, volume));
313313
return false;
314314
}
315315

316316
// check capacity
317317
List<Pair<Volume, DiskProfile>> requestVolumeDiskProfilePairs = new ArrayList<>();
318318
requestVolumeDiskProfilePairs.add(new Pair<>(volume, dskCh));
319319
if (dskCh.getHypervisorType() == HypervisorType.VMware) {
320-
// Skip the parent datastore cluster, consider only child storage pools in it
321320
if (pool.getPoolType() == Storage.StoragePoolType.DatastoreCluster && storageMgr.isStoragePoolDatastoreClusterParent(pool)) {
321+
s_logger.debug(String.format("Skipping allocation of pool [%s] to volume [%s] because this pool is a parent datastore cluster.", pool, volume));
322322
return false;
323323
}
324-
// Skip the storage pool whose parent datastore cluster is not in UP state.
325324
if (pool.getParent() != 0L) {
326325
StoragePoolVO datastoreCluster = storagePoolDao.findById(pool.getParent());
327326
if (datastoreCluster == null || (datastoreCluster != null && datastoreCluster.getStatus() != StoragePoolStatus.Up)) {
327+
s_logger.debug(String.format("Skipping allocation of pool [%s] to volume [%s] because this pool is not in [%s] state.", datastoreCluster, volume, StoragePoolStatus.Up));
328328
return false;
329329
}
330330
}
331331

332332
try {
333333
boolean isStoragePoolStoragepolicyComplaince = storageMgr.isStoragePoolCompliantWithStoragePolicy(requestVolumeDiskProfilePairs, pool);
334334
if (!isStoragePoolStoragepolicyComplaince) {
335+
s_logger.debug(String.format("Skipping allocation of pool [%s] to volume [%s] because this pool is not compliant with the storage policy required by the volume.", pool, volume));
335336
return false;
336337
}
337338
} catch (StorageUnavailableException e) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmPr
100100
}
101101
StoragePool storagePool = (StoragePool)dataStoreMgr.getPrimaryDataStore(pool.getId());
102102
if (filter(avoid, storagePool, dskCh, plan)) {
103-
s_logger.trace(String.format("Found suitable local storage pool [%s], adding to list.", pool));
103+
s_logger.debug(String.format("Found suitable local storage pool [%s] to allocate disk [%s] to it, adding to list.", pool, dskCh));
104104
suitablePools.add(storagePool);
105105
} else {
106+
s_logger.debug(String.format("Adding storage pool [%s] to avoid set during allocation of disk [%s].", pool, dskCh));
106107
avoid.addPool(pool.getId());
107108
}
108109
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmPr
8282
if (pool != null && pool.isLocal()) {
8383
StoragePool storagePool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId());
8484
if (filter(avoid, storagePool, dskCh, plan)) {
85-
s_logger.trace(String.format("Found suitable local storage pool [%s], adding to list.", pool));
85+
s_logger.debug(String.format("Found suitable local storage pool [%s] to allocate disk [%s] to it, adding to list.", pool, dskCh));
8686
suitablePools.add(storagePool);
8787
} else {
88+
s_logger.debug(String.format("Adding storage pool [%s] to avoid set during allocation of disk [%s].", pool, dskCh));
8889
avoid.addPool(pool.getId());
8990
}
9091
}
@@ -107,8 +108,10 @@ protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmPr
107108
}
108109
StoragePool storagePool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId());
109110
if (filter(avoid, storagePool, dskCh, plan)) {
111+
s_logger.debug(String.format("Found suitable local storage pool [%s] to allocate disk [%s] to it, adding to list.", pool, dskCh));
110112
suitablePools.add(storagePool);
111113
} else {
114+
s_logger.debug(String.format("Adding storage pool [%s] to avoid set during allocation of disk [%s].", pool, dskCh));
112115
avoid.addPool(pool.getId());
113116
}
114117
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmPr
9494
}
9595
StoragePool storagePool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(storage.getId());
9696
if (filter(avoid, storagePool, dskCh, plan)) {
97-
LOGGER.trace(String.format("Found suitable local storage pool [%s], adding to list.", storage));
97+
LOGGER.debug(String.format("Found suitable local storage pool [%s] to allocate disk [%s] to it, adding to list.", storagePool, dskCh));
9898
suitablePools.add(storagePool);
9999
} else {
100100
if (canAddStoragePoolToAvoidSet(storage)) {
101+
LOGGER.debug(String.format("Adding storage pool [%s] to avoid set during allocation of disk [%s].", storagePool, dskCh));
101102
avoid.addPool(storagePool.getId());
102103
}
103104
}

server/src/main/java/com/cloud/storage/StorageManagerImpl.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,6 +2388,7 @@ private long getUsedSize(StoragePool pool) {
23882388
@Override
23892389
public boolean storagePoolHasEnoughIops(List<Pair<Volume, DiskProfile>> requestedVolumes, StoragePool pool) {
23902390
if (requestedVolumes == null || requestedVolumes.isEmpty() || pool == null) {
2391+
s_logger.debug(String.format("Cannot check if storage [%s] has enough IOPS to allocate volumes [%s].", pool, requestedVolumes));
23912392
return false;
23922393
}
23932394

@@ -2418,8 +2419,10 @@ public boolean storagePoolHasEnoughIops(List<Pair<Volume, DiskProfile>> requeste
24182419
}
24192420

24202421
long futureIops = currentIops + requestedIops;
2421-
2422-
return futureIops <= pool.getCapacityIops();
2422+
boolean hasEnoughIops = futureIops <= pool.getCapacityIops();
2423+
String hasCapacity = hasEnoughIops ? "has" : "does not have";
2424+
s_logger.debug(String.format("Pool [%s] %s enough IOPS to allocate volumes [%s].", pool, hasCapacity, requestedVolumes));
2425+
return hasEnoughIops;
24232426
}
24242427

24252428
@Override
@@ -2430,10 +2433,12 @@ public boolean storagePoolHasEnoughSpace(List<Pair<Volume, DiskProfile>> volumeD
24302433
@Override
24312434
public boolean storagePoolHasEnoughSpace(List<Pair<Volume, DiskProfile>> volumeDiskProfilesList, StoragePool pool, Long clusterId) {
24322435
if (CollectionUtils.isEmpty(volumeDiskProfilesList)) {
2436+
s_logger.debug(String.format("Cannot check if pool [%s] has enough space to allocate volumes because the volumes list is empty.", pool));
24332437
return false;
24342438
}
24352439

24362440
if (!checkUsagedSpace(pool)) {
2441+
s_logger.debug(String.format("Cannot allocate pool [%s] because there is not enough space in this pool.", pool));
24372442
return false;
24382443
}
24392444

@@ -2696,30 +2701,34 @@ private long getBytesRequiredForTemplate(VMTemplateVO tmpl, StoragePool pool) {
26962701
@Override
26972702
public boolean storagePoolCompatibleWithVolumePool(StoragePool pool, Volume volume) {
26982703
if (pool == null || volume == null) {
2704+
s_logger.debug(String.format("Cannot check if storage pool [%s] is compatible with volume [%s].", pool, volume));
26992705
return false;
27002706
}
27012707

27022708
if (volume.getPoolId() == null) {
2703-
// Volume is not allocated to any pool. Not possible to check compatibility with other pool, let it try
2709+
s_logger.debug(String.format("Volume [%s] is not allocated to any pool. Cannot check compatibility with pool [%s].", volume, pool));
27042710
return true;
27052711
}
27062712

27072713
StoragePool volumePool = _storagePoolDao.findById(volume.getPoolId());
27082714
if (volumePool == null) {
2709-
// Volume pool doesn't exist. Not possible to check compatibility with other pool, let it try
2715+
s_logger.debug(String.format("Pool [%s] used by volume [%s] does not exist. Cannot check compatibility.", pool, volume));
27102716
return true;
27112717
}
27122718

27132719
if (volume.getState() == Volume.State.Ready) {
27142720
if (volumePool.getPoolType() == Storage.StoragePoolType.PowerFlex && pool.getPoolType() != Storage.StoragePoolType.PowerFlex) {
2721+
s_logger.debug(String.format("Pool [%s] with type [%s] does not match volume [%s] pool type [%s].", pool, pool.getPoolType(), volume, volumePool.getPoolType()));
27152722
return false;
27162723
} else if (volumePool.getPoolType() != Storage.StoragePoolType.PowerFlex && pool.getPoolType() == Storage.StoragePoolType.PowerFlex) {
2724+
s_logger.debug(String.format("Pool [%s] with type [%s] does not match volume [%s] pool type [%s].", pool, pool.getPoolType(), volume, volumePool.getPoolType()));
27172725
return false;
27182726
}
27192727
} else {
2728+
s_logger.debug(String.format("Cannot check compatibility of pool [%s] because volume [%s] is not in [%s] state.", pool, volume, Volume.State.Ready));
27202729
return false;
27212730
}
2722-
2731+
s_logger.debug(String.format("Pool [%s] is compatible with volume [%s].", pool, volume));
27232732
return true;
27242733
}
27252734

0 commit comments

Comments
 (0)