fix snapshot physical size for primary storage (#11448)

This commit is contained in:
João Jandre 2025-08-15 11:22:50 -03:00 committed by GitHub
parent 9111bbd8da
commit c6daeb4f78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 3 deletions

View File

@ -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;
}