This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.15
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.15 by this push:
new 5051fde server: Stat collector solidfire capacity fix (#4918)
5051fde is described below
commit 5051fde952b038536cedf6cc05e31796cff0c842
Author: Rohit Yadav <[email protected]>
AuthorDate: Wed Apr 21 12:48:11 2021 +0530
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 <[email protected]>
---
.../main/java/com/cloud/server/StatsCollector.java | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/server/src/main/java/com/cloud/server/StatsCollector.java
b/server/src/main/java/com/cloud/server/StatsCollector.java
index 86db544..50f1063 100644
--- a/server/src/main/java/com/cloud/server/StatsCollector.java
+++ b/server/src/main/java/com/cloud/server/StatsCollector.java
@@ -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);
}
}