rhtyd commented on a change in pull request #4918:
URL: https://github.com/apache/cloudstack/pull/4918#discussion_r613823326



##########
File path: server/src/main/java/com/cloud/server/StatsCollector.java
##########
@@ -1020,14 +1020,18 @@ protected void runInContext() {
                         if (answer != null && answer.getResult()) {
                             storagePoolStats.put(pool.getId(), 
(StorageStats)answer);
 
+                            boolean poolNeedsUpdating = false;
                             // Seems like we have dynamically updated the pool 
size since the prev. size and the current do not match
-                            if (pool.getCapacityBytes() != 
((StorageStats)answer).getCapacityBytes() ||
-                                    pool.getUsedBytes() != 
((StorageStats)answer).getByteUsed()) {
+                            if (_storagePoolStats.get(poolId) != null && 
_storagePoolStats.get(poolId).getCapacityBytes() != 
((StorageStats)answer).getCapacityBytes()) {
                                 
pool.setCapacityBytes(((StorageStats)answer).getCapacityBytes());
-                                if 
(pool.getStorageProviderName().equalsIgnoreCase(DataStoreProvider.DEFAULT_PRIMARY))
 {
-                                    pool.setUsedBytes(((StorageStats) 
answer).getByteUsed());
-                                    pool.setUpdateTime(new Date());
-                                }
+                                poolNeedsUpdating = true;
+                            }
+                            if (pool.getUsedBytes() != 
((StorageStats)answer).getByteUsed() && 
pool.getStorageProviderName().equalsIgnoreCase(DataStoreProvider.DEFAULT_PRIMARY)
 && ((StorageStats)answer).getByteUsed() > 0) {

Review comment:
       When pool is added to cloudstack or cloudstack is restarted, if the pool 
is empty the usage will be set to 0. I see that case, let me see what/how can 
we handle that. This change was recently added in 4.15 only.




-- 
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