From 2b6cb6fa9bbda12b8529c596b2e53fdfcd3e5216 Mon Sep 17 00:00:00 2001 From: sr73318 Date: Mon, 10 Aug 2026 23:33:47 +0530 Subject: [PATCH 1/3] CSTACKEX-241: adding in the updatestoragepool of provider's lifecycle --- .../com/cloud/storage/StorageManagerImpl.java | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java index b25da50d4d92..5654eb3fcfe2 100644 --- a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java @@ -1285,30 +1285,28 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I changes = true; } - if (changes) { - StoragePoolVO storagePool = _storagePoolDao.findById(id); - DataStoreProvider dataStoreProvider = _dataStoreProviderMgr.getDataStoreProvider(storagePool.getStorageProviderName()); - DataStoreLifeCycle dataStoreLifeCycle = dataStoreProvider.getDataStoreLifeCycle(); - - if (dataStoreLifeCycle instanceof PrimaryDataStoreLifeCycle) { - if (updatedCapacityBytes != null) { - details.put(PrimaryDataStoreLifeCycle.CAPACITY_BYTES, updatedCapacityBytes != null ? String.valueOf(updatedCapacityBytes) : null); - _storagePoolDao.updateCapacityBytes(id, updatedCapacityBytes); - } - if (updatedCapacityIops != null) { - details.put(PrimaryDataStoreLifeCycle.CAPACITY_IOPS, updatedCapacityIops != null ? String.valueOf(updatedCapacityIops) : null); - _storagePoolDao.updateCapacityIops(id, updatedCapacityIops); - } - if (cmd.getUrl() != null) { - details.put("url", cmd.getUrl()); - } - _storagePoolDao.update(id, storagePool); - _storagePoolDao.updateDetails(id, details); - } - } - - return (PrimaryDataStoreInfo)_dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); - } + if (changes) { + DataStoreProvider dataStoreProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName()); + DataStoreLifeCycle dataStoreLifeCycle = dataStoreProvider.getDataStoreLifeCycle(); + if (dataStoreLifeCycle instanceof PrimaryDataStoreLifeCycle) { + if (updatedCapacityBytes != null) { + details.put(PrimaryDataStoreLifeCycle.CAPACITY_BYTES, String.valueOf(updatedCapacityBytes)); + pool.setCapacityBytes(updatedCapacityBytes); + } + if (updatedCapacityIops != null) { + details.put(PrimaryDataStoreLifeCycle.CAPACITY_IOPS, String.valueOf(updatedCapacityIops)); + pool.setCapacityIops(updatedCapacityIops); + } + if (cmd.getUrl() != null) { + details.put("url", cmd.getUrl()); + } + ((PrimaryDataStoreLifeCycle)dataStoreLifeCycle).updateStoragePool(pool, details); + _storagePoolDao.update(id, pool); + _storagePoolDao.updateDetails(id, details); + } + } + return (PrimaryDataStoreInfo)_dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); + } private void changeStoragePoolScopeToZone(StoragePoolVO primaryStorage) { /* From 3b0816b6fa33f37f11880521ce6419b8a282700a Mon Sep 17 00:00:00 2001 From: sr73318 Date: Tue, 11 Aug 2026 08:50:17 +0530 Subject: [PATCH 2/3] CSTACKEX-241: fixing the formatting --- .../com/cloud/storage/StorageManagerImpl.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java index 5654eb3fcfe2..1dd6453d9e5a 100644 --- a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java @@ -1285,28 +1285,28 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I changes = true; } - if (changes) { - DataStoreProvider dataStoreProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName()); - DataStoreLifeCycle dataStoreLifeCycle = dataStoreProvider.getDataStoreLifeCycle(); - if (dataStoreLifeCycle instanceof PrimaryDataStoreLifeCycle) { - if (updatedCapacityBytes != null) { - details.put(PrimaryDataStoreLifeCycle.CAPACITY_BYTES, String.valueOf(updatedCapacityBytes)); - pool.setCapacityBytes(updatedCapacityBytes); - } - if (updatedCapacityIops != null) { - details.put(PrimaryDataStoreLifeCycle.CAPACITY_IOPS, String.valueOf(updatedCapacityIops)); - pool.setCapacityIops(updatedCapacityIops); - } - if (cmd.getUrl() != null) { - details.put("url", cmd.getUrl()); - } - ((PrimaryDataStoreLifeCycle)dataStoreLifeCycle).updateStoragePool(pool, details); - _storagePoolDao.update(id, pool); - _storagePoolDao.updateDetails(id, details); - } - } - return (PrimaryDataStoreInfo)_dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); - } + if (changes) { + DataStoreProvider dataStoreProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName()); + DataStoreLifeCycle dataStoreLifeCycle = dataStoreProvider.getDataStoreLifeCycle(); + if (dataStoreLifeCycle instanceof PrimaryDataStoreLifeCycle) { + if (updatedCapacityBytes != null) { + details.put(PrimaryDataStoreLifeCycle.CAPACITY_BYTES, String.valueOf(updatedCapacityBytes)); + pool.setCapacityBytes(updatedCapacityBytes); + } + if (updatedCapacityIops != null) { + details.put(PrimaryDataStoreLifeCycle.CAPACITY_IOPS, String.valueOf(updatedCapacityIops)); + pool.setCapacityIops(updatedCapacityIops); + } + if (cmd.getUrl() != null) { + details.put("url", cmd.getUrl()); + } + ((PrimaryDataStoreLifeCycle)dataStoreLifeCycle).updateStoragePool(pool, details); + _storagePoolDao.update(id, pool); + _storagePoolDao.updateDetails(id, details); + } + } + return (PrimaryDataStoreInfo)_dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); + } private void changeStoragePoolScopeToZone(StoragePoolVO primaryStorage) { /* From 7115082a78db4584e7d1917c8004a358361b40c3 Mon Sep 17 00:00:00 2001 From: sr73318 Date: Thu, 13 Aug 2026 08:49:24 +0530 Subject: [PATCH 3/3] CSTACKEX-241: resolving comments --- .../com/cloud/storage/StorageManagerImpl.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java index 1dd6453d9e5a..1e56df74c607 100644 --- a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java @@ -1260,10 +1260,18 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I boolean changes = false; Long updatedCapacityBytes = null; Long capacityBytes = cmd.getCapacityBytes(); + // retrieve current details and merge/overlay input to capture changes + Map details = null; + details = _storagePoolDetailsDao.listDetailsKeyPairs(id); + if (inputDetails != null) { + details.putAll(inputDetails); + changes = true; + } if (capacityBytes != null) { if (capacityBytes != pool.getCapacityBytes()) { updatedCapacityBytes = capacityBytes; + details.put(PrimaryDataStoreLifeCycle.CAPACITY_BYTES, String.valueOf(updatedCapacityBytes)); changes = true; } } @@ -1273,34 +1281,25 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I if (capacityIops != null) { if (!capacityIops.equals(pool.getCapacityIops())) { updatedCapacityIops = capacityIops; + details.put(PrimaryDataStoreLifeCycle.CAPACITY_IOPS, String.valueOf(updatedCapacityIops)); changes = true; } } - // retrieve current details and merge/overlay input to capture changes - Map details = null; - details = _storagePoolDetailsDao.listDetailsKeyPairs(id); - if (inputDetails != null) { - details.putAll(inputDetails); - changes = true; - } - if (changes) { DataStoreProvider dataStoreProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName()); DataStoreLifeCycle dataStoreLifeCycle = dataStoreProvider.getDataStoreLifeCycle(); if (dataStoreLifeCycle instanceof PrimaryDataStoreLifeCycle) { + if (cmd.getUrl() != null) { + details.put("url", cmd.getUrl()); + } + ((PrimaryDataStoreLifeCycle)dataStoreLifeCycle).updateStoragePool(pool, details); if (updatedCapacityBytes != null) { - details.put(PrimaryDataStoreLifeCycle.CAPACITY_BYTES, String.valueOf(updatedCapacityBytes)); pool.setCapacityBytes(updatedCapacityBytes); } if (updatedCapacityIops != null) { - details.put(PrimaryDataStoreLifeCycle.CAPACITY_IOPS, String.valueOf(updatedCapacityIops)); pool.setCapacityIops(updatedCapacityIops); } - if (cmd.getUrl() != null) { - details.put("url", cmd.getUrl()); - } - ((PrimaryDataStoreLifeCycle)dataStoreLifeCycle).updateStoragePool(pool, details); _storagePoolDao.update(id, pool); _storagePoolDao.updateDetails(id, details); }