mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-10222: Clean snaphosts from primary storage when taking new (#2398)
When user creates a snapshot (manual or recurring), snapshot remains on the primary storage, even if the snapshot is transferred successfully to secondary storage. This is causing issues because XenServer can only hold a limited number of snapshots in its VDI chain, preventing the user from creating new snapshots after some time, when too many old snapshots are present on the primary storage.
This commit is contained in:
parent
6ffbce6159
commit
94776fbfd0
|
|
@ -1071,7 +1071,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean destroySnapshotOnPrimaryStorage(final Connection conn, final String lastSnapshotUuid) {
|
||||
protected boolean destroySnapshotOnPrimaryStorage(final Connection conn, final String lastSnapshotUuid) {
|
||||
try {
|
||||
final VDI snapshot = getVDIbyUuid(conn, lastSnapshotUuid);
|
||||
if (snapshot == null) {
|
||||
|
|
|
|||
|
|
@ -559,12 +559,12 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor {
|
|||
physicalSize = Long.parseLong(tmp[1]);
|
||||
finalPath = folder + File.separator + snapshotBackupUuid + ".vhd";
|
||||
}
|
||||
|
||||
final String volumeUuid = snapshotTO.getVolume().getPath();
|
||||
|
||||
destroySnapshotOnPrimaryStorageExceptThis(conn, volumeUuid, snapshotUuid);
|
||||
}
|
||||
|
||||
// remove every snapshot except this one from primary storage
|
||||
final String volumeUuid = snapshotTO.getVolume().getPath();
|
||||
destroySnapshotOnPrimaryStorageExceptThis(conn, volumeUuid, snapshotUuid);
|
||||
|
||||
final SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
|
||||
newSnapshot.setPath(finalPath);
|
||||
newSnapshot.setPhysicalSize(physicalSize);
|
||||
|
|
@ -577,12 +577,13 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor {
|
|||
s_logger.info("New snapshot physical utilization: "+physicalSize);
|
||||
|
||||
return new CopyCmdAnswer(newSnapshot);
|
||||
} catch (final Types.XenAPIException e) {
|
||||
details = "BackupSnapshot Failed due to " + e.toString();
|
||||
s_logger.warn(details, e);
|
||||
} catch (final Exception e) {
|
||||
details = "BackupSnapshot Failed due to " + e.getMessage();
|
||||
final String reason = e instanceof Types.XenAPIException ? e.toString() : e.getMessage();
|
||||
details = "BackupSnapshot Failed due to " + reason;
|
||||
s_logger.warn(details, e);
|
||||
|
||||
// remove last bad primary snapshot when exception happens
|
||||
destroySnapshotOnPrimaryStorage(conn, snapshotUuid);
|
||||
}
|
||||
|
||||
return new CopyCmdAnswer(details);
|
||||
|
|
|
|||
Loading…
Reference in New Issue