Skip to content

Commit c6daeb4

Browse files
authored
fix snapshot physical size for primary storage (#11448)
1 parent 9111bbd commit c6daeb4

File tree

1 file changed

+8
-3
lines changed
  • engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot

1 file changed

+8
-3
lines changed

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,15 @@ public boolean isRevertable() {
172172
@Override
173173
public long getPhysicalSize() {
174174
long physicalSize = 0;
175-
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findByStoreSnapshot(DataStoreRole.Image, store.getId(), snapshot.getId());
176-
if (snapshotStore != null) {
177-
physicalSize = snapshotStore.getPhysicalSize();
175+
for (DataStoreRole role : List.of(DataStoreRole.Image, DataStoreRole.Primary)) {
176+
logger.trace("Retrieving snapshot [{}] size from {} storage.", snapshot.getUuid(), role);
177+
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findByStoreSnapshot(role, store.getId(), snapshot.getId());
178+
if (snapshotStore != null) {
179+
return snapshotStore.getPhysicalSize();
180+
}
181+
logger.trace("Snapshot [{}] size not found on {} storage.", snapshot.getUuid(), role);
178182
}
183+
logger.warn("Snapshot [{}] reference not found in any storage. There may be an inconsistency on the database.", snapshot.getUuid());
179184
return physicalSize;
180185
}
181186

0 commit comments

Comments
 (0)