server: Stat collector solidfire capacity fix (#4918)

Fixes regression introduced in 71c5dbcf492a023dbea5f8c34f8fd883c3ad653f
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>
This commit is contained in:
Rohit Yadav 2021-04-21 12:48:11 +05:30 committed by GitHub
parent 8edd709cad
commit 5051fde952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1020,14 +1020,22 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
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()) {
pool.setCapacityBytes(((StorageStats)answer).getCapacityBytes());
if (pool.getStorageProviderName().equalsIgnoreCase(DataStoreProvider.DEFAULT_PRIMARY)) {
pool.setUsedBytes(((StorageStats) answer).getByteUsed());
pool.setUpdateTime(new Date());
if (_storagePoolStats.get(poolId) != null && _storagePoolStats.get(poolId).getCapacityBytes() != ((StorageStats)answer).getCapacityBytes()) {
if (((StorageStats)answer).getCapacityBytes() > 0) {
pool.setCapacityBytes(((StorageStats)answer).getCapacityBytes());
poolNeedsUpdating = true;
} else {
s_logger.warn("Not setting capacity bytes, received " + ((StorageStats)answer).getCapacityBytes() + " capacity for pool ID " + poolId);
}
}
if (pool.getUsedBytes() != ((StorageStats)answer).getByteUsed() && pool.getStorageProviderName().equalsIgnoreCase(DataStoreProvider.DEFAULT_PRIMARY)) {
pool.setUsedBytes(((StorageStats) answer).getByteUsed());
poolNeedsUpdating = true;
}
if (poolNeedsUpdating) {
pool.setUpdateTime(new Date());
_storagePoolDao.update(pool.getId(), pool);
}
}