This is an automated email from the ASF dual-hosted git repository.

sureshanaparti pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 9111bbd8da67a256e59a5401aced8fac3cc2ca39
Merge: f5b4858012b 25f93b1d6b8
Author: Suresh Kumar Anaparti <sureshkumar.anapa...@gmail.com>
AuthorDate: Fri Aug 15 19:49:59 2025 +0530

    Merge branch '4.19' into 4.20

 plugins/storage/volume/linstor/CHANGELOG.md        |  6 +++++
 .../driver/LinstorPrimaryDataStoreDriverImpl.java  | 30 +++++++++++++---------
 ui/src/views/infra/zone/ZoneWizardLaunchZone.vue   | 12 ++++-----
 3 files changed, 30 insertions(+), 18 deletions(-)

diff --cc 
plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java
index a0999090355,0eefe0bcf9b..306e9259936
--- 
a/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java
+++ 
b/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java
@@@ -1535,11 -1533,12 +1535,12 @@@ public class LinstorPrimaryDataStoreDri
  
      /**
       * Updates the cache map containing current allocated size data.
-      * @param api Linstor Developers api object
+      * @param linstorAddr Linstor cluster api address
       */
-     private void fillVolumeStatsCache(DevelopersApi api) {
+     private void fillVolumeStatsCache(String linstorAddr) {
+         final DevelopersApi api = LinstorUtil.getLinstorAPI(linstorAddr);
          try {
-             logger.trace("Start volume stats cache update");
 -            s_logger.trace("Start volume stats cache update for " + 
linstorAddr);
++            logger.trace("Start volume stats cache update for " + 
linstorAddr);
              List<ResourceWithVolumes> resources = api.viewResources(
                      Collections.emptyList(),
                      Collections.emptyList(),
@@@ -1570,25 -1569,30 +1571,30 @@@
              for (Map.Entry<String, Long> entry : allocSizeMap.entrySet()) {
                  Long reserved = resSizeMap.getOrDefault(entry.getKey(), 0L);
                  Pair<Long, Long> volStat = new Pair<>(entry.getValue(), 
reserved);
-                 volumeStats.put(entry.getKey(), volStat);
+                 volumeStats.put(linstorAddr + "/" + entry.getKey(), volStat);
              }
-             volumeStatsLastUpdate = System.currentTimeMillis();
-             logger.trace("Done volume stats cache update: {}", 
volumeStats.size());
+             volumeStatsLastUpdate.put(linstorAddr, 
System.currentTimeMillis());
 -            s_logger.debug(String.format("Done volume stats cache update for 
%s: %d", linstorAddr, volumeStats.size()));
++            logger.debug(String.format("Done volume stats cache update for 
%s: %d", linstorAddr, volumeStats.size()));
          } catch (ApiException e) {
 -            s_logger.error("Unable to fetch Linstor resources: " + 
e.getBestMessage());
 +            logger.error("Unable to fetch Linstor resources: {}", 
e.getBestMessage());
          }
      }
  
      @Override
      public Pair<Long, Long> getVolumeStats(StoragePool storagePool, String 
volumeId) {
-         final DevelopersApi api = 
LinstorUtil.getLinstorAPI(storagePool.getHostAddress());
+         String linstorAddr = storagePool.getHostAddress();
          synchronized (volumeStats) {
-             long invalidateCacheTime = volumeStatsLastUpdate +
+             long invalidateCacheTime = 
volumeStatsLastUpdate.getOrDefault(storagePool.getHostAddress(), 0L) +
                      LinstorConfigurationManager.VolumeStatsCacheTime.value() 
* 1000;
              if (invalidateCacheTime < System.currentTimeMillis()) {
-                 fillVolumeStatsCache(api);
+                 fillVolumeStatsCache(storagePool.getHostAddress());
+             }
+             String volumeKey = linstorAddr + "/" + LinstorUtil.RSC_PREFIX + 
volumeId;
+             Pair<Long, Long> sizePair = volumeStats.get(volumeKey);
+             if (sizePair == null) {
 -                s_logger.warn(String.format("Volumestats for %s not found in 
cache", volumeKey));
++                logger.warn(String.format("Volumestats for %s not found in 
cache", volumeKey));
              }
-             return volumeStats.get(LinstorUtil.RSC_PREFIX + volumeId);
+             return sizePair;
          }
      }
  

Reply via email to