mirror of https://github.com/apache/cloudstack.git
server: Clean up the duplicate volume when the destination managed volume creation failed on migrate volume operation (#4730)
Duplicated volumes after failed migration in Allocated state Fix: Clean up the duplicate volume when the destination managed volume creation failed on migrate volume operation
This commit is contained in:
parent
ebc529b9cc
commit
45e77dd6f0
|
|
@ -1123,12 +1123,6 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
// Refresh the volume info from the DB.
|
||||
volumeInfo = volFactory.getVolume(volumeInfo.getId(), destPrimaryDataStore);
|
||||
|
||||
volumeInfo.processEvent(Event.CreateRequested);
|
||||
CreateVolumeFromBaseImageContext<VolumeApiResult> context = new CreateVolumeFromBaseImageContext<>(null, volumeInfo, destPrimaryDataStore, srcTemplateOnPrimary, future, null, null);
|
||||
AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
|
||||
caller.setCallback(caller.getTarget().createVolumeFromBaseManagedImageCallBack(null, null));
|
||||
caller.setContext(context);
|
||||
|
||||
Map<String, String> details = new HashMap<String, String>();
|
||||
details.put(PrimaryDataStore.MANAGED, Boolean.TRUE.toString());
|
||||
details.put(PrimaryDataStore.STORAGE_HOST, destPrimaryDataStore.getHostAddress());
|
||||
|
|
@ -1141,6 +1135,13 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
|
||||
grantAccess(volumeInfo, destHost, destPrimaryDataStore);
|
||||
|
||||
volumeInfo.processEvent(Event.CreateRequested);
|
||||
|
||||
CreateVolumeFromBaseImageContext<VolumeApiResult> context = new CreateVolumeFromBaseImageContext<>(null, volumeInfo, destPrimaryDataStore, srcTemplateOnPrimary, future, null, null);
|
||||
AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
|
||||
caller.setCallback(caller.getTarget().createVolumeFromBaseManagedImageCallBack(null, null));
|
||||
caller.setContext(context);
|
||||
|
||||
try {
|
||||
motionSrv.copyAsync(srcTemplateOnPrimary, volumeInfo, destHost, caller);
|
||||
} finally {
|
||||
|
|
@ -1919,6 +1920,11 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
AsyncCallFuture<VolumeApiResult> createVolumeFuture = createVolumeAsync(destVolume, destStore);
|
||||
VolumeApiResult createVolumeResult = createVolumeFuture.get();
|
||||
if (createVolumeResult.isFailed()) {
|
||||
s_logger.debug("Failed to create dest volume " + destVolume.getId() + ", volume can be removed");
|
||||
destroyVolume(destVolume.getId());
|
||||
destVolume.processEvent(Event.ExpungeRequested);
|
||||
destVolume.processEvent(Event.OperationSuccessed);
|
||||
volDao.remove(destVolume.getId());
|
||||
throw new CloudRuntimeException("Creation of a dest volume failed: " + createVolumeResult.getResult());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue