Skip to content

Commit 3bbdedc

Browse files
JoaoJandredhslove
authored andcommitted
fix snapshot physical size for primary storage (apache#11448)
1 parent 4298287 commit 3bbdedc

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
@@ -204,10 +204,15 @@ public boolean isRevertable() {
204204
@Override
205205
public long getPhysicalSize() {
206206
long physicalSize = 0;
207-
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findByStoreSnapshot(DataStoreRole.Image, store.getId(), snapshot.getId());
208-
if (snapshotStore != null) {
209-
physicalSize = snapshotStore.getPhysicalSize();
207+
for (DataStoreRole role : List.of(DataStoreRole.Image, DataStoreRole.Primary)) {
208+
logger.trace("Retrieving snapshot [{}] size from {} storage.", snapshot.getUuid(), role);
209+
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findByStoreSnapshot(role, store.getId(), snapshot.getId());
210+
if (snapshotStore != null) {
211+
return snapshotStore.getPhysicalSize();
212+
}
213+
logger.trace("Snapshot [{}] size not found on {} storage.", snapshot.getUuid(), role);
210214
}
215+
logger.warn("Snapshot [{}] reference not found in any storage. There may be an inconsistency on the database.", snapshot.getUuid());
211216
return physicalSize;
212217
}
213218

0 commit comments

Comments
 (0)