mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-7842: wrong size column is getting updated with snapshot physical size in snapshot_store_ref table.
Also fixed the issue that snapshot size with hypervisor XS >= 6.2.5 is not getting updated in snapshot_store_ref table.
This commit is contained in:
parent
6490694231
commit
5a67fe7369
|
|
@ -288,7 +288,7 @@ public class SnapshotObject implements SnapshotInfo {
|
|||
snapshotStore.setInstallPath(snapshotTO.getPath());
|
||||
if (snapshotTO.getPhysicalSize() != null) {
|
||||
// For S3 delta snapshot, physical size is currently not set
|
||||
snapshotStore.setSize(snapshotTO.getPhysicalSize());
|
||||
snapshotStore.setPhysicalSize(snapshotTO.getPhysicalSize());
|
||||
}
|
||||
if (snapshotTO.getParentSnapshotPath() == null) {
|
||||
snapshotStore.setParentSnapshotId(0L);
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
|||
ss.setRole(dataStore.getRole());
|
||||
ss.setVolumeId(snapshotInfo.getVolumeId());
|
||||
ss.setSize(snapshotInfo.getSize()); // this is the virtual size of snapshot in primary storage.
|
||||
ss.setPhysicalSize(snapshotInfo.getSize()); // this physical size will get updated with actual size once the snapshot backup is done.
|
||||
SnapshotDataStoreVO snapshotDataStoreVO = snapshotDataStoreDao.findParent(dataStore.getRole(), dataStore.getId(), snapshotInfo.getVolumeId());
|
||||
if (snapshotDataStoreVO != null) {
|
||||
ss.setParentSnapshotId(snapshotDataStoreVO.getSnapshotId());
|
||||
|
|
@ -156,7 +157,7 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
|||
ss.setSnapshotId(obj.getId());
|
||||
ss.setDataStoreId(dataStore.getId());
|
||||
ss.setRole(dataStore.getRole());
|
||||
ss.setRole(dataStore.getRole());
|
||||
ss.setSize(snapshot.getSize());
|
||||
ss.setVolumeId(snapshot.getVolumeId());
|
||||
SnapshotDataStoreVO snapshotDataStoreVO = snapshotDataStoreDao.findParent(dataStore.getRole(), dataStore.getId(), snapshot.getVolumeId());
|
||||
if (snapshotDataStoreVO != null) {
|
||||
|
|
|
|||
|
|
@ -329,8 +329,8 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor {
|
|||
}
|
||||
}
|
||||
}
|
||||
String backupUuid = dvdi.getUuid(conn);
|
||||
return backupUuid;
|
||||
String result = dvdi.getUuid(conn).concat("#").concat(dvdi.getPhysicalUtilisation(conn).toString());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
String msg = "Exception in backupsnapshot stage due to " + e.toString();
|
||||
s_logger.debug(msg);
|
||||
|
|
@ -392,6 +392,7 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor {
|
|||
String details = null;
|
||||
String snapshotBackupUuid = null;
|
||||
boolean fullbackup = Boolean.parseBoolean(options.get("fullSnapshot"));
|
||||
Long physicalSize = null;
|
||||
try {
|
||||
SR primaryStorageSR = hypervisorResource.getSRByNameLabelandHost(conn, primaryStorageNameLabel);
|
||||
if (primaryStorageSR == null) {
|
||||
|
|
@ -431,6 +432,7 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor {
|
|||
hypervisorResource.checkForSuccess(conn, task);
|
||||
VDI backedVdi = Types.toVDI(task, conn);
|
||||
snapshotBackupUuid = backedVdi.getUuid(conn);
|
||||
physicalSize = backedVdi.getPhysicalUtilisation(conn);
|
||||
|
||||
if( destStore instanceof SwiftTO) {
|
||||
try {
|
||||
|
|
@ -488,9 +490,11 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor {
|
|||
throw new CloudRuntimeException("S3 upload of snapshots " + snapshotPaUuid + " failed");
|
||||
}
|
||||
} else {
|
||||
snapshotBackupUuid = backupSnapshot(conn, primaryStorageSRUuid, localMountPoint, folder,
|
||||
String result = backupSnapshot(conn, primaryStorageSRUuid, localMountPoint, folder,
|
||||
secondaryStorageMountPath, snapshotUuid, prevBackupUuid, prevSnapshotUuid, isISCSI, wait);
|
||||
|
||||
String[] tmp = result.split("#");
|
||||
snapshotBackupUuid = tmp[0];
|
||||
physicalSize = Long.parseLong(tmp[1]);
|
||||
finalPath = folder + File.separator + snapshotBackupUuid;
|
||||
}
|
||||
}
|
||||
|
|
@ -499,6 +503,7 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor {
|
|||
|
||||
SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
|
||||
newSnapshot.setPath(finalPath);
|
||||
newSnapshot.setPhysicalSize(physicalSize);
|
||||
if (fullbackup) {
|
||||
newSnapshot.setParentSnapshotPath(null);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
|
|||
templateSizeSearch.done();
|
||||
|
||||
snapshotSizeSearch = _snapshotDataStoreDao.createSearchBuilder(SumCount.class);
|
||||
snapshotSizeSearch.select("sum", Func.SUM, snapshotSizeSearch.entity().getSize());
|
||||
snapshotSizeSearch.select("sum", Func.SUM, snapshotSizeSearch.entity().getPhysicalSize());
|
||||
snapshotSizeSearch.and("state", snapshotSizeSearch.entity().getState(), Op.EQ);
|
||||
snapshotSizeSearch.and("storeRole", snapshotSizeSearch.entity().getRole(), Op.EQ);
|
||||
SearchBuilder<SnapshotVO> join2 = _snapshotDao.createSearchBuilder();
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
if (snapshotCheck.getState() != Snapshot.State.Error && snapshotCheck.getState() != Snapshot.State.Destroyed)
|
||||
_resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.snapshot);
|
||||
if (snapshotCheck.getState() == Snapshot.State.BackedUp)
|
||||
_resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.secondary_storage, new Long(snapshotStoreRef.getSize()));
|
||||
_resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.secondary_storage, new Long(snapshotStoreRef.getPhysicalSize()));
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
|
|
@ -624,7 +624,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
if (Type.MANUAL == snapshot.getRecurringType()) {
|
||||
_resourceLimitMgr.decrementResourceCount(accountId, ResourceType.snapshot);
|
||||
if (snapshotStoreRef != null) {
|
||||
_resourceLimitMgr.decrementResourceCount(accountId, ResourceType.secondary_storage, new Long(snapshotStoreRef.getSize()));
|
||||
_resourceLimitMgr.decrementResourceCount(accountId, ResourceType.secondary_storage, new Long(snapshotStoreRef.getPhysicalSize()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -973,11 +973,10 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
try {
|
||||
postCreateSnapshot(volume.getId(), snapshotId, payload.getSnapshotPolicyId());
|
||||
SnapshotDataStoreVO snapshotStoreRef = _snapshotStoreDao.findBySnapshot(snapshotId, DataStoreRole.Image);
|
||||
// FIXME - snapshotStoreRef.getSize() refers to physical size, correct that
|
||||
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_CREATE, snapshot.getAccountId(), snapshot.getDataCenterId(), snapshotId, snapshot.getName(),
|
||||
null, null, snapshotStoreRef.getSize(), volume.getSize(), snapshot.getClass().getName(), snapshot.getUuid());
|
||||
null, null, snapshotStoreRef.getPhysicalSize(), volume.getSize(), snapshot.getClass().getName(), snapshot.getUuid());
|
||||
// Correct the resource count of snapshot in case of delta snapshots.
|
||||
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.secondary_storage, new Long(volume.getSize() - snapshotStoreRef.getSize()));
|
||||
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.secondary_storage, new Long(volume.getSize() - snapshotStoreRef.getPhysicalSize()));
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("post process snapshot failed", e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue