sureshanaparti commented on a change in pull request #4790:
URL: https://github.com/apache/cloudstack/pull/4790#discussion_r639417891



##########
File path: server/src/main/java/com/cloud/server/StatsCollector.java
##########
@@ -1367,10 +1372,28 @@ public boolean imageStoreHasEnoughCapacity(DataStore 
imageStore) {
         if (!_storageStats.keySet().contains(imageStore.getId())) { // Stats 
not available for this store yet, can be a new store. Better to assume it has 
enough capacity?
             return true;
         }
-        StorageStats imageStoreStats = _storageStats.get(imageStore.getId());
-        if (imageStoreStats != null && (imageStoreStats.getByteUsed() / 
(imageStoreStats.getCapacityBytes() * 1.0)) <= _imageStoreCapacityThreshold) {
+
+        long imageStoreId = imageStore.getId();
+        StorageStats imageStoreStats = _storageStats.get(imageStoreId);
+
+        if (imageStoreStats == null) {
+            s_logger.debug(String.format("Stats for image store [%s] not 
found.", imageStoreId));
+            return false;
+        }
+
+        double totalCapacity = imageStoreStats.getCapacityBytes();
+        double usedCapacity = imageStoreStats.getByteUsed();
+        double threshold = getImageStoreCapacityThreshold();
+        String readableTotalCapacity = FileUtils.byteCountToDisplaySize((long) 
totalCapacity);
+        String readableUsedCapacity = FileUtils.byteCountToDisplaySize((long) 
usedCapacity);
+
+        s_logger.debug(String.format("Verifying image storage [%s]. Capacity: 
total=[%s], used=[%s], threshold=[%s%%].", imageStoreId, readableTotalCapacity, 
readableUsedCapacity, threshold * 100));
+
+        if (usedCapacity / totalCapacity <= threshold) {
             return true;
         }
+
+        s_logger.warn(String.format("Image storage [%s] has not enough 
capacity. Capacity: total=[%s], used=[%s], threshold=[%s%%].", 
imageStoreId,readableTotalCapacity, readableUsedCapacity, threshold * 100));

Review comment:
       ```suggestion
           s_logger.warn(String.format("Image storage [%s] has not enough 
capacity.", imageStoreId));
   ```
   
   capacity/used bytes and threshold already logged above, may not be required 
here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to