This is an automated email from the ASF dual-hosted git repository. dahn pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push: new 817251f1f89 Enhancement in the accuracy of the logs regarding the capacity, usage, and threshold of secondary storages (#9043) 817251f1f89 is described below commit 817251f1f8955a15232b6ee8032534ae64ff9921 Author: Lucas Martins <56271185+lucas-a-mart...@users.noreply.github.com> AuthorDate: Wed Jul 24 10:30:40 2024 -0300 Enhancement in the accuracy of the logs regarding the capacity, usage, and threshold of secondary storages (#9043) Co-authored-by: Lucas Martins <lucas.mart...@scclouds.com.br> --- server/src/main/java/com/cloud/server/StatsCollector.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/com/cloud/server/StatsCollector.java b/server/src/main/java/com/cloud/server/StatsCollector.java index ac9ee06f772..70959b56cfd 100644 --- a/server/src/main/java/com/cloud/server/StatsCollector.java +++ b/server/src/main/java/com/cloud/server/StatsCollector.java @@ -64,10 +64,10 @@ import org.apache.cloudstack.utils.identity.ManagementServerNode; import org.apache.cloudstack.utils.usage.UsageUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; -import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; +import org.apache.logging.log4j.Level; import org.influxdb.BatchOptions; import org.influxdb.InfluxDB; import org.influxdb.InfluxDBFactory; @@ -1714,7 +1714,8 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc pool.setCapacityBytes(capacityBytes); poolNeedsUpdating = true; } else { - logger.warn("Not setting capacity bytes, received " + ((StorageStats)answer).getCapacityBytes() + " capacity for pool ID " + poolId); + logger.warn("Not setting capacity bytes, received {} capacity for pool ID {}", + NumbersUtil.toReadableSize(((StorageStats)answer).getCapacityBytes()), poolId); } } if (((_storagePoolStats.get(poolId) != null && _storagePoolStats.get(poolId).getByteUsed() != usedBytes) @@ -1831,16 +1832,15 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc double totalCapacity = imageStoreStats.getCapacityBytes(); double usedCapacity = imageStoreStats.getByteUsed(); double threshold = getImageStoreCapacityThreshold(); - String readableTotalCapacity = FileUtils.byteCountToDisplaySize((long) totalCapacity); - String readableUsedCapacity = FileUtils.byteCountToDisplaySize((long) usedCapacity); - - logger.debug(String.format("Verifying image storage [%s]. Capacity: total=[%s], used=[%s], threshold=[%s%%].", imageStoreId, readableTotalCapacity, readableUsedCapacity, threshold * 100)); + String readableTotalCapacity = NumbersUtil.toReadableSize((long) totalCapacity); + String readableUsedCapacity = NumbersUtil.toReadableSize((long) usedCapacity); + logger.printf(Level.DEBUG, "Verifying image storage [%s]. Capacity: total=[%s], used=[%s], threshold=[%.2f%%].", imageStoreId, readableTotalCapacity, readableUsedCapacity, threshold * 100); if (usedCapacity / totalCapacity <= threshold) { return true; } - logger.warn(String.format("Image storage [%s] has not enough capacity. Capacity: total=[%s], used=[%s], threshold=[%s%%].", imageStoreId, readableTotalCapacity, readableUsedCapacity, threshold * 100)); + logger.printf(Level.WARN, "Image storage [%s] has not enough capacity. Capacity: total=[%s], used=[%s], threshold=[%.2f%%].", imageStoreId, readableTotalCapacity, readableUsedCapacity, threshold * 100); return false; }