Skip to content

Commit b01f631

Browse files
devdeepAbhinandan Prateek
authored andcommitted
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>
1 parent f98ce5d commit b01f631

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ public AsyncCallFuture<VolumeApiResult> copyVolume(VolumeInfo srcVolume,
521521

522522
VolumeVO destVol = duplicateVolumeOnAnotherStorage(srcVolume, (StoragePool)destStore);
523523
VolumeInfo destVolume = this.volFactory.getVolume(destVol.getId(), destStore);
524-
destVolume.processEvent(Event.CreateOnlyRequested);
525-
srcVolume.processEvent(Event.CopyingRequested);
524+
destVolume.processEvent(Event.MigrationRequested);
525+
srcVolume.processEvent(Event.MigrationRequested);
526526

527527
CopyVolumeContext<VolumeApiResult> context = new CopyVolumeContext<VolumeApiResult>(null, future, srcVolume,
528528
destVolume,
@@ -550,13 +550,17 @@ protected Void copyVolumeCallBack(AsyncCallbackDispatcher<VolumeServiceImpl, Cop
550550
res.setResult(result.getResult());
551551
destVolume.processEvent(Event.OperationFailed);
552552
srcVolume.processEvent(Event.OperationFailed);
553+
destroyVolume(destVolume.getId());
554+
destVolume = this.volFactory.getVolume(destVolume.getId());
553555
AsyncCallFuture<VolumeApiResult> destroyFuture = this.expungeVolumeAsync(destVolume);
554556
destroyFuture.get();
555557
future.complete(res);
556558
return null;
557559
}
558560
srcVolume.processEvent(Event.OperationSuccessed);
559561
destVolume.processEvent(Event.OperationSuccessed);
562+
destroyVolume(srcVolume.getId());
563+
srcVolume = this.volFactory.getVolume(srcVolume.getId());
560564
AsyncCallFuture<VolumeApiResult> destroyFuture = this.expungeVolumeAsync(srcVolume);
561565
destroyFuture.get();
562566
future.complete(res);

0 commit comments

Comments
 (0)