You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2026/09/08 11:57:51 UTC

(cloudstack) branch main updated: server: treat a zero-capacity storage pool as full (#14052)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new a53c5ae2404 server: treat a zero-capacity storage pool as full (#14052)
a53c5ae2404 is described below

commit a53c5ae2404b2bc78f65534ada3f421024af94aa
Author: Ramgopal Nagaboina <ra...@gmail.com>
AuthorDate: Tue Sep 8 07:57:44 2026 -0400

    server: treat a zero-capacity storage pool as full (#14052)
---
 .../src/main/java/com/cloud/storage/StorageManagerImpl.java   |  3 +++
 .../test/java/com/cloud/storage/StorageManagerImplTest.java   | 11 +++++++++++
 2 files changed, 14 insertions(+)

diff --git a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java
index 4d2bfb47de1..69f04393174 100644
--- a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java
@@ -3444,6 +3444,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
         }
 
         long totalSize = pool.getCapacityBytes();
+        if (totalSize <= 0) {
+            return false;
+        }
         long usedSize = getUsedSize(pool);
         double usedPercentage = ((double)usedSize / (double)totalSize);
         double storageUsedThreshold = CapacityManager.StorageCapacityDisableThreshold.valueIn(pool.getId());
diff --git a/server/src/test/java/com/cloud/storage/StorageManagerImplTest.java b/server/src/test/java/com/cloud/storage/StorageManagerImplTest.java
index 8f88800d549..f46699f88cf 100644
--- a/server/src/test/java/com/cloud/storage/StorageManagerImplTest.java
+++ b/server/src/test/java/com/cloud/storage/StorageManagerImplTest.java
@@ -1716,4 +1716,15 @@ public class StorageManagerImplTest {
 
         storageManagerImpl.discoverObjectStore(name, url, size, providerName, details);
     }
+
+    @Test
+    public void checkUsagedSpaceReturnsFalseForZeroCapacityPool() {
+        StoragePool pool = Mockito.mock(StoragePool.class);
+        Mockito.when(pool.isManaged()).thenReturn(false);
+        Mockito.when(pool.getCapacityBytes()).thenReturn(0L);
+
+        Boolean result = ReflectionTestUtils.invokeMethod(storageManagerImpl, "checkUsagedSpace", pool);
+
+        Assert.assertFalse(result);
+    }
 }