mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
CLOUDSTACK-8122. Handle NPE thrown during migration failures.
When migration fails instead of returning NULL, throw the exception.
This commit is contained in:
parent
ac491c9607
commit
a5a65c7b55
@ -937,10 +937,10 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
return result.getVolume();
|
||||
} catch (InterruptedException e) {
|
||||
s_logger.debug("migrate volume failed", e);
|
||||
return null;
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
} catch (ExecutionException e) {
|
||||
s_logger.debug("migrate volume failed", e);
|
||||
return null;
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1795,6 +1795,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
if (jobResult != null) {
|
||||
if (jobResult instanceof ConcurrentOperationException)
|
||||
throw (ConcurrentOperationException)jobResult;
|
||||
else if (jobResult instanceof RuntimeException)
|
||||
throw (RuntimeException)jobResult;
|
||||
else if (jobResult instanceof Throwable)
|
||||
throw new RuntimeException("Unexpected exception", (Throwable)jobResult);
|
||||
}
|
||||
@ -1817,35 +1819,39 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
assert (destPool != null);
|
||||
|
||||
Volume newVol = null;
|
||||
if (liveMigrateVolume) {
|
||||
newVol = liveMigrateVolume(vol, destPool);
|
||||
} else {
|
||||
try {
|
||||
try {
|
||||
if (liveMigrateVolume) {
|
||||
newVol = liveMigrateVolume(vol, destPool);
|
||||
} else {
|
||||
newVol = _volumeMgr.migrateVolume(vol, destPool);
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.debug("Failed to migrate volume", e);
|
||||
}
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.debug("Failed to migrate volume", e);
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Failed to migrate volume", e);
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
return newVol;
|
||||
}
|
||||
|
||||
@DB
|
||||
protected Volume liveMigrateVolume(Volume volume, StoragePool destPool) {
|
||||
protected Volume liveMigrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException {
|
||||
VolumeInfo vol = volFactory.getVolume(volume.getId());
|
||||
AsyncCallFuture<VolumeApiResult> future = volService.migrateVolume(vol, (DataStore)destPool);
|
||||
try {
|
||||
VolumeApiResult result = future.get();
|
||||
if (result.isFailed()) {
|
||||
s_logger.debug("migrate volume failed:" + result.getResult());
|
||||
return null;
|
||||
throw new StorageUnavailableException("Migrate volume failed: " + result.getResult(), destPool.getId());
|
||||
}
|
||||
return result.getVolume();
|
||||
} catch (InterruptedException e) {
|
||||
s_logger.debug("migrate volume failed", e);
|
||||
return null;
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
} catch (ExecutionException e) {
|
||||
s_logger.debug("migrate volume failed", e);
|
||||
return null;
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user