From b01f63123fff00fe40cdd46d741f29dec05fcc8d Mon Sep 17 00:00:00 2001 From: Devdeep Singh Date: Fri, 19 Apr 2013 14:43:55 +0530 Subject: [PATCH] CS-1879: NPE while migrating volume. The state transitions on the volume that has to be migrated were incorrect. A volume to be migrated is in ready state and cannot be transitioned to copying state. Similarly, the duplicated volume is in ready state too and cannot be transitioned to creating state. Fixed it by transitioning the volume to migrating state when a migrateVolume api call is made. Also, a volume has to be destroyed first before it can be expunged. Fixed that too. Signed-off-by: Abhinandan Prateek --- .../cloudstack/storage/volume/VolumeServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index e3526debd6e..b39502b1924 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -521,8 +521,8 @@ public class VolumeServiceImpl implements VolumeService { VolumeVO destVol = duplicateVolumeOnAnotherStorage(srcVolume, (StoragePool)destStore); VolumeInfo destVolume = this.volFactory.getVolume(destVol.getId(), destStore); - destVolume.processEvent(Event.CreateOnlyRequested); - srcVolume.processEvent(Event.CopyingRequested); + destVolume.processEvent(Event.MigrationRequested); + srcVolume.processEvent(Event.MigrationRequested); CopyVolumeContext context = new CopyVolumeContext(null, future, srcVolume, destVolume, @@ -550,6 +550,8 @@ public class VolumeServiceImpl implements VolumeService { res.setResult(result.getResult()); destVolume.processEvent(Event.OperationFailed); srcVolume.processEvent(Event.OperationFailed); + destroyVolume(destVolume.getId()); + destVolume = this.volFactory.getVolume(destVolume.getId()); AsyncCallFuture destroyFuture = this.expungeVolumeAsync(destVolume); destroyFuture.get(); future.complete(res); @@ -557,6 +559,8 @@ public class VolumeServiceImpl implements VolumeService { } srcVolume.processEvent(Event.OperationSuccessed); destVolume.processEvent(Event.OperationSuccessed); + destroyVolume(srcVolume.getId()); + srcVolume = this.volFactory.getVolume(srcVolume.getId()); AsyncCallFuture destroyFuture = this.expungeVolumeAsync(srcVolume); destroyFuture.get(); future.complete(res);