Skip to content

Commit 374de76

Browse files
committed
CLOUDSTACK-4324: need to clean up snapshot_store_ref, if creating snapshot failed.
1 parent 0f60b5d commit 374de76

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ public SnapshotResult takeSnapshot(SnapshotInfo snap) {
214214
try {
215215
result = future.get();
216216
if (result.isFailed()) {
217-
s_logger.debug("Failed to create snapshot:" + result.getResult());
217+
snapshot.processEvent(Snapshot.Event.OperationFailed);
218+
snapshot.processEvent(Event.OperationFailed);
218219
throw new CloudRuntimeException(result.getResult());
219220
}
220221
return result;
@@ -224,8 +225,10 @@ public SnapshotResult takeSnapshot(SnapshotInfo snap) {
224225
} catch (ExecutionException e) {
225226
s_logger.debug("Failed to create snapshot", e);
226227
throw new CloudRuntimeException("Failed to create snapshot", e);
228+
} catch (NoTransitionException e) {
229+
s_logger.debug("Failed to create snapshot", e);
230+
throw new CloudRuntimeException("Failed to create snapshot", e);
227231
}
228-
229232
}
230233

231234
// if a snapshot has parent snapshot, the new snapshot should be stored in

‎plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,11 @@ public Answer copyVolumeFromImageCacheToPrimary(CopyCommand cmd) {
352352
secondaryStoragePool = storagePoolMgr.getStoragePoolByURI(
353353
secondaryStorageUrl + File.separator + volumeDir
354354
);
355+
if (!srcVolumeName.endsWith(".qcow2")) {
356+
srcVolumeName = srcVolumeName + ".qcow2";
357+
}
355358
KVMPhysicalDisk volume = secondaryStoragePool
356-
.getPhysicalDisk(srcVolumeName + ".qcow2");
359+
.getPhysicalDisk(srcVolumeName);
357360
storagePoolMgr.copyPhysicalDisk(volume, volumeName,
358361
primaryPool);
359362
VolumeObjectTO newVol = new VolumeObjectTO();
@@ -414,7 +417,7 @@ public Answer copyVolumeFromPrimaryToSecondary(CopyCommand cmd) {
414417
storagePoolMgr.copyPhysicalDisk(volume,
415418
destVolumeName,secondaryStoragePool);
416419
VolumeObjectTO newVol = new VolumeObjectTO();
417-
newVol.setPath(destVolumePath + File.separator + volumeName);
420+
newVol.setPath(destVolumePath + File.separator + destVolumeName);
418421
return new CopyCmdAnswer(newVol);
419422
} catch (CloudRuntimeException e) {
420423
return new CopyCmdAnswer(e.toString());

0 commit comments

Comments
 (0)