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


The following commit(s) were added to refs/heads/4.20 by this push:
     new c6daeb4f78d fix snapshot physical size for primary storage (#11448)
c6daeb4f78d is described below

commit c6daeb4f78d5cd7c8865657aa49cce9bee6609aa
Author: João Jandre <[email protected]>
AuthorDate: Fri Aug 15 11:22:50 2025 -0300

    fix snapshot physical size for primary storage (#11448)
---
 .../apache/cloudstack/storage/snapshot/SnapshotObject.java    | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git 
a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
 
b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
index a3964bd461e..7602a142f88 100644
--- 
a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
+++ 
b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
@@ -172,10 +172,15 @@ public class SnapshotObject implements SnapshotInfo {
     @Override
     public long getPhysicalSize() {
         long physicalSize = 0;
-        SnapshotDataStoreVO snapshotStore = 
snapshotStoreDao.findByStoreSnapshot(DataStoreRole.Image, store.getId(), 
snapshot.getId());
-        if (snapshotStore != null) {
-            physicalSize = snapshotStore.getPhysicalSize();
+        for (DataStoreRole role : List.of(DataStoreRole.Image, 
DataStoreRole.Primary)) {
+            logger.trace("Retrieving snapshot [{}] size from {} storage.", 
snapshot.getUuid(), role);
+            SnapshotDataStoreVO snapshotStore = 
snapshotStoreDao.findByStoreSnapshot(role, store.getId(), snapshot.getId());
+            if (snapshotStore != null) {
+                return snapshotStore.getPhysicalSize();
+            }
+            logger.trace("Snapshot [{}] size not found on {} storage.", 
snapshot.getUuid(), role);
         }
+        logger.warn("Snapshot [{}] reference not found in any storage. There 
may be an inconsistency on the database.", snapshot.getUuid());
         return physicalSize;
     }
 

Reply via email to