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 <aprateek@apache.org>
This commit is contained in:
Devdeep Singh 2013-04-19 14:43:55 +05:30 committed by Abhinandan Prateek
parent f98ce5ddcc
commit b01f63123f
1 changed files with 6 additions and 2 deletions

View File

@ -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);