CLOUDSTACK-8569: The latter snapshot export for the same volume will fail is 2 snapshot exports are queued

This closes #469
This commit is contained in:
Sanjay Tripathi 2015-06-17 15:16:43 +05:30
parent 47278556f5
commit d702b63bfb
1 changed files with 6 additions and 1 deletions

View File

@ -1157,10 +1157,15 @@ public class XenServerStorageProcessor implements StorageProcessor {
if (volume == null) {
throw new InternalErrorException("Could not destroy snapshot on volume " + volumeUuid + " due to can not find it");
}
// To avoid deleting snapshots which are still waiting in queue to get backed up.
VDI avoidSnapshot = getVDIbyUuid(conn, avoidSnapshotUuid);
if (avoidSnapshot == null) {
throw new InternalErrorException("Could not find current snapshot " + avoidSnapshotUuid);
}
final Set<VDI> snapshots = volume.getSnapshots(conn);
for (final VDI snapshot : snapshots) {
try {
if (!snapshot.getUuid(conn).equals(avoidSnapshotUuid)) {
if (!snapshot.getUuid(conn).equals(avoidSnapshotUuid) && snapshot.getSnapshotTime(conn).before(avoidSnapshot.getSnapshotTime(conn))) {
snapshot.destroy(conn);
}
} catch (final Exception e) {