Skip to content

Commit 5051fde

Browse files
authored
server: Stat collector solidfire capacity fix (#4918)
Fixes regression introduced in 71c5dbc which would cause capacity bytes of certain pools to be update which shouldn't get updated by StatsCollector such as solidfire. Fixes #4911 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 8edd709 commit 5051fde

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

server/src/main/java/com/cloud/server/StatsCollector.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,14 +1020,22 @@ protected void runInContext() {
10201020
if (answer != null && answer.getResult()) {
10211021
storagePoolStats.put(pool.getId(), (StorageStats)answer);
10221022

1023+
boolean poolNeedsUpdating = false;
10231024
// Seems like we have dynamically updated the pool size since the prev. size and the current do not match
1024-
if (pool.getCapacityBytes() != ((StorageStats)answer).getCapacityBytes() ||
1025-
pool.getUsedBytes() != ((StorageStats)answer).getByteUsed()) {
1026-
pool.setCapacityBytes(((StorageStats)answer).getCapacityBytes());
1027-
if (pool.getStorageProviderName().equalsIgnoreCase(DataStoreProvider.DEFAULT_PRIMARY)) {
1028-
pool.setUsedBytes(((StorageStats) answer).getByteUsed());
1029-
pool.setUpdateTime(new Date());
1025+
if (_storagePoolStats.get(poolId) != null && _storagePoolStats.get(poolId).getCapacityBytes() != ((StorageStats)answer).getCapacityBytes()) {
1026+
if (((StorageStats)answer).getCapacityBytes() > 0) {
1027+
pool.setCapacityBytes(((StorageStats)answer).getCapacityBytes());
1028+
poolNeedsUpdating = true;
1029+
} else {
1030+
s_logger.warn("Not setting capacity bytes, received " + ((StorageStats)answer).getCapacityBytes() + " capacity for pool ID " + poolId);
10301031
}
1032+
}
1033+
if (pool.getUsedBytes() != ((StorageStats)answer).getByteUsed() && pool.getStorageProviderName().equalsIgnoreCase(DataStoreProvider.DEFAULT_PRIMARY)) {
1034+
pool.setUsedBytes(((StorageStats) answer).getByteUsed());
1035+
poolNeedsUpdating = true;
1036+
}
1037+
if (poolNeedsUpdating) {
1038+
pool.setUpdateTime(new Date());
10311039
_storagePoolDao.update(pool.getId(), pool);
10321040
}
10331041
}

0 commit comments

Comments
 (0)