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 <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b01f6312 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b01f6312 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b01f6312 Branch: refs/heads/ui-vm-affinity Commit: b01f63123fff00fe40cdd46d741f29dec05fcc8d Parents: f98ce5d Author: Devdeep Singh <[email protected]> Authored: Fri Apr 19 14:43:55 2013 +0530 Committer: Abhinandan Prateek <[email protected]> Committed: Fri Apr 19 16:15:24 2013 +0530 ---------------------------------------------------------------------- .../storage/volume/VolumeServiceImpl.java | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b01f6312/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java ---------------------------------------------------------------------- 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 e3526de..b39502b 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<VolumeApiResult> context = new CopyVolumeContext<VolumeApiResult>(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<VolumeApiResult> 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<VolumeApiResult> destroyFuture = this.expungeVolumeAsync(srcVolume); destroyFuture.get(); future.complete(res);
