-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add logs for storage pools reordering #10419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.22
Are you sure you want to change the base?
Changes from all commits
2f2dafa
f0186a6
04e69aa
b69581a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -145,10 +145,10 @@ | |||||
| storageType = "shared"; | ||||||
| } | ||||||
|
|
||||||
| logger.debug(String.format( | ||||||
| "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.", | ||||||
| logger.info( | ||||||
| "Filtering storage pools by capacity type [{}] as the first storage pool of the list, with name [{}] and ID [{}], is a [{}] storage.", | ||||||
| capacityType, storagePool.getName(), storagePool.getUuid(), storageType | ||||||
| )); | ||||||
| ); | ||||||
|
|
||||||
| Pair<List<Long>, Map<Long, Double>> result = capacityDao.orderHostsByFreeCapacity(zoneId, clusterId, capacityType); | ||||||
| List<Long> poolIdsByCapacity = result.first(); | ||||||
|
|
@@ -185,7 +185,7 @@ | |||||
| Long clusterId = plan.getClusterId(); | ||||||
|
|
||||||
| List<Long> poolIdsByVolCount = volumeDao.listPoolIdsByVolumeCount(dcId, podId, clusterId, account.getAccountId()); | ||||||
| logger.debug(String.format("List of pools in ascending order of number of volumes for account [%s] is [%s].", account, poolIdsByVolCount)); | ||||||
| logger.debug("List of pools in ascending order of number of volumes for account [{}] is [{}].", account, poolIdsByVolCount); | ||||||
|
|
||||||
| // now filter the given list of Pools by this ordered list | ||||||
| Map<Long, StoragePool> poolMap = new HashMap<>(); | ||||||
|
|
@@ -206,16 +206,11 @@ | |||||
|
|
||||||
| @Override | ||||||
| public List<StoragePool> reorderPools(List<StoragePool> pools, VirtualMachineProfile vmProfile, DeploymentPlan plan, DiskProfile dskCh) { | ||||||
| if (logger.isTraceEnabled()) { | ||||||
| logger.trace("reordering pools"); | ||||||
| } | ||||||
| if (pools == null) { | ||||||
| logger.trace("There are no pools to reorder; returning null."); | ||||||
| logger.info("There are no pools to reorder."); | ||||||
|
Check warning on line 210 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
|
||||||
| return null; | ||||||
| } | ||||||
| if (logger.isTraceEnabled()) { | ||||||
| logger.trace(String.format("reordering %d pools", pools.size())); | ||||||
| } | ||||||
| logger.info("Reordering [{}] pools", pools.size()); | ||||||
|
Check warning on line 213 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
|
||||||
| Account account = null; | ||||||
| if (vmProfile.getVirtualMachine() != null) { | ||||||
| account = vmProfile.getOwner(); | ||||||
|
|
@@ -224,9 +219,7 @@ | |||||
| pools = reorderStoragePoolsBasedOnAlgorithm(pools, plan, account); | ||||||
|
|
||||||
| if (vmProfile.getVirtualMachine() == null) { | ||||||
| if (logger.isTraceEnabled()) { | ||||||
| logger.trace("The VM is null, skipping pools reordering by disk provisioning type."); | ||||||
| } | ||||||
| logger.info("The VM is null, skipping pool reordering by disk provisioning type."); | ||||||
|
Check warning on line 222 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
|
||||||
| return pools; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -240,14 +233,10 @@ | |||||
|
|
||||||
| List<StoragePool> reorderStoragePoolsBasedOnAlgorithm(List<StoragePool> pools, DeploymentPlan plan, Account account) { | ||||||
| String volumeAllocationAlgorithm = VolumeOrchestrationService.VolumeAllocationAlgorithm.value(); | ||||||
| logger.debug("Using volume allocation algorithm {} to reorder pools.", volumeAllocationAlgorithm); | ||||||
| logger.info("Using volume allocation algorithm {} to reorder pools.", volumeAllocationAlgorithm); | ||||||
| if (volumeAllocationAlgorithm.equals("random") || volumeAllocationAlgorithm.equals("userconcentratedpod_random") || (account == null)) { | ||||||
| reorderRandomPools(pools); | ||||||
| } else if (StringUtils.equalsAny(volumeAllocationAlgorithm, "userdispersing", "firstfitleastconsumed")) { | ||||||
| if (logger.isTraceEnabled()) { | ||||||
| logger.trace("Using reordering algorithm {}", volumeAllocationAlgorithm); | ||||||
| } | ||||||
|
|
||||||
| if (volumeAllocationAlgorithm.equals("userdispersing")) { | ||||||
| pools = reorderPoolsByNumberOfVolumes(plan, pools, account); | ||||||
| } else { | ||||||
|
|
@@ -259,16 +248,15 @@ | |||||
|
|
||||||
| void reorderRandomPools(List<StoragePool> pools) { | ||||||
| StorageUtil.traceLogStoragePools(pools, logger, "pools to choose from: "); | ||||||
| if (logger.isTraceEnabled()) { | ||||||
| logger.trace("Shuffle this so that we don't check the pools in the same order. Algorithm == 'random' (or no account?)"); | ||||||
| } | ||||||
| StorageUtil.traceLogStoragePools(pools, logger, "pools to shuffle: "); | ||||||
| logger.trace("Shuffle this so that we don't check the pools in the same order. Algorithm == 'random' (or no account?)"); | ||||||
| logger.debug("Pools to shuffle: [{}]", pools); | ||||||
| Collections.shuffle(pools, secureRandom); | ||||||
| StorageUtil.traceLogStoragePools(pools, logger, "shuffled list of pools to choose from: "); | ||||||
| logger.debug("Shuffled list of pools to choose from: [{}]", pools); | ||||||
| } | ||||||
|
|
||||||
| private List<StoragePool> reorderPoolsByDiskProvisioningType(List<StoragePool> pools, DiskProfile diskProfile) { | ||||||
| if (diskProfile != null && diskProfile.getProvisioningType() != null && !diskProfile.getProvisioningType().equals(Storage.ProvisioningType.THIN)) { | ||||||
| logger.info("Reordering [{}] pools by disk provisioning type [{}].", pools.size(), diskProfile.getProvisioningType()); | ||||||
|
Check warning on line 259 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
|
||||||
| List<StoragePool> reorderedPools = new ArrayList<>(); | ||||||
| int preferredIndex = 0; | ||||||
| for (StoragePool pool : pools) { | ||||||
|
|
@@ -282,22 +270,28 @@ | |||||
| reorderedPools.add(preferredIndex++, pool); | ||||||
| } | ||||||
| } | ||||||
| logger.debug("Reordered list of pools by disk provisioning type [{}]: [{}]", diskProfile.getProvisioningType(), pools); | ||||||
|
Check warning on line 273 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
|
||||||
|
||||||
| logger.debug("Reordered list of pools by disk provisioning type [{}]: [{}]", diskProfile.getProvisioningType(), pools); | |
| logger.debug("Reordered list of pools by disk provisioning type [{}]: [{}]", diskProfile.getProvisioningType(), reorderedPools); |
Check warning on line 277 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L277
Added line #L277 was not covered by tests
Check warning on line 279 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L279
Added line #L279 was not covered by tests
Check warning on line 286 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L286
Added line #L286 was not covered by tests
Check warning on line 288 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L288
Added line #L288 was not covered by tests
Check warning on line 294 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L294
Added line #L294 was not covered by tests
Check warning on line 316 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L316
Added line #L316 was not covered by tests
Check warning on line 329 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L329
Added line #L329 was not covered by tests
Check warning on line 340 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L340
Added line #L340 was not covered by tests
Check warning on line 346 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L346
Added line #L346 was not covered by tests
Check warning on line 355 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L355
Added line #L355 was not covered by tests
Check warning on line 361 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L361
Added line #L361 was not covered by tests
Check warning on line 371 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L371
Added line #L371 was not covered by tests
Check warning on line 375 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L375
Added line #L375 was not covered by tests
Check warning on line 424 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L424
Added line #L424 was not covered by tests
Check warning on line 431 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L430-L431
Added lines #L430 - L431 were not covered by tests
Check warning on line 436 in engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
Codecov / codecov/patch
engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java#L435-L436
Added lines #L435 - L436 were not covered by tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These log statements (and similar ones added below) have been raised to INFO level, which means every pool reordering attempt will now be emitted at INFO instead of DEBUG/TRACE and can significantly increase log volume in busy environments. This also goes beyond the PR description (which mentioned adding DEBUG logs and promoting TRACE to DEBUG), so please confirm that INFO is the intended level for these high-frequency paths or consider keeping them at DEBUG while still adopting the new Log4j2 placeholder syntax.