mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix volume migration failure response (#10707)
This commit is contained in:
parent
40d549b075
commit
a09354ddf5
@ -5104,9 +5104,9 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes
|
||||
answer.setVolumeChainInfo(chainInfo);
|
||||
return answer;
|
||||
} catch (Exception e) {
|
||||
String msg = "Catch Exception " + e.getClass().getName() + " due to " + e.toString();
|
||||
String msg = "Catch Exception " + e.getClass().getName() + " due to " + e.getMessage();
|
||||
logger.error(msg, e);
|
||||
return new MigrateVolumeAnswer(cmd, false, msg, null);
|
||||
return new MigrateVolumeAnswer(cmd, false, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -260,7 +260,7 @@ public class VmwareStorageMotionStrategy implements DataMotionStrategy {
|
||||
} else {
|
||||
answer = agentMgr.sendTo(sourcePool.getDataCenterId(), HypervisorType.VMware, cmd);
|
||||
}
|
||||
updateVolumeAfterMigration(answer, srcData, destData);
|
||||
handleAnswerAndUpdateVolumeAfterMigration(answer, srcData, destData);
|
||||
CopyCommandResult result = new CopyCommandResult(null, answer);
|
||||
callback.complete(result);
|
||||
}
|
||||
@ -286,21 +286,19 @@ public class VmwareStorageMotionStrategy implements DataMotionStrategy {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
private void updateVolumeAfterMigration(Answer answer, DataObject srcData, DataObject destData) {
|
||||
private void handleAnswerAndUpdateVolumeAfterMigration(Answer answer, DataObject srcData, DataObject destData) {
|
||||
VolumeVO destinationVO = volDao.findById(destData.getId());
|
||||
if (!(answer instanceof MigrateVolumeAnswer)) {
|
||||
// OfflineVmwareMigration: reset states and such
|
||||
VolumeVO sourceVO = volDao.findById(srcData.getId());
|
||||
sourceVO.setState(Volume.State.Ready);
|
||||
volDao.update(sourceVO.getId(), sourceVO);
|
||||
if (destinationVO.getId() != sourceVO.getId()) {
|
||||
destinationVO.setState(Volume.State.Expunged);
|
||||
destinationVO.setRemoved(new Date());
|
||||
volDao.update(destinationVO.getId(), destinationVO);
|
||||
}
|
||||
resetVolumeState(srcData, destinationVO);
|
||||
throw new CloudRuntimeException("unexpected answer from hypervisor agent: " + answer.getDetails());
|
||||
}
|
||||
MigrateVolumeAnswer ans = (MigrateVolumeAnswer) answer;
|
||||
if (!answer.getResult()) {
|
||||
String msg = "Unable to migrate volume: " + srcData.getName() + " due to " + answer.getDetails();
|
||||
resetVolumeState(srcData, destinationVO);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
String format = "retrieved '%s' as new path for volume(%d)";
|
||||
logger.debug(String.format(format, ans.getVolumePath(), destData.getId()));
|
||||
@ -311,6 +309,17 @@ public class VmwareStorageMotionStrategy implements DataMotionStrategy {
|
||||
volDao.update(destinationVO.getId(), destinationVO);
|
||||
}
|
||||
|
||||
private void resetVolumeState(DataObject srcData, VolumeVO destinationVO) {
|
||||
VolumeVO sourceVO = volDao.findById(srcData.getId());
|
||||
sourceVO.setState(Volume.State.Ready);
|
||||
volDao.update(sourceVO.getId(), sourceVO);
|
||||
if (destinationVO.getId() != sourceVO.getId()) {
|
||||
destinationVO.setState(Volume.State.Expunged);
|
||||
destinationVO.setRemoved(new Date());
|
||||
volDao.update(destinationVO.getId(), destinationVO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
|
||||
Answer answer = null;
|
||||
|
||||
@ -3738,7 +3738,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
VolumeApiResult result = future.get();
|
||||
if (result.isFailed()) {
|
||||
logger.debug("migrate volume failed:" + result.getResult());
|
||||
throw new StorageUnavailableException("Migrate volume failed: " + result.getResult(), destPool.getId());
|
||||
throw new CloudRuntimeException("Migrate volume failed: " + result.getResult());
|
||||
}
|
||||
return result.getVolume();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user