mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8350: Volume attachment failed when user stops the VM during attaching DISK.
This commit is contained in:
parent
7144e9b35d
commit
5f59091418
@ -1210,7 +1210,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||||||
destPrimaryStorage = _storagePoolDao.findById(exstingVolumeOfVm.getPoolId());
|
destPrimaryStorage = _storagePoolDao.findById(exstingVolumeOfVm.getPoolId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destPrimaryStorage != null && (volumeToAttach.getState() == Volume.State.Allocated || volumeToAttach.getState() == Volume.State.Uploaded)) {
|
boolean volumeOnSecondary = volumeToAttach.getState() == Volume.State.Uploaded;
|
||||||
|
|
||||||
|
if (destPrimaryStorage != null && (volumeToAttach.getState() == Volume.State.Allocated || volumeOnSecondary)) {
|
||||||
try {
|
try {
|
||||||
newVolumeOnPrimaryStorage = _volumeMgr.createVolumeOnPrimaryStorage(vm, volumeToAttach, rootDiskHyperType, destPrimaryStorage);
|
newVolumeOnPrimaryStorage = _volumeMgr.createVolumeOnPrimaryStorage(vm, volumeToAttach, rootDiskHyperType, destPrimaryStorage);
|
||||||
} catch (NoTransitionException e) {
|
} catch (NoTransitionException e) {
|
||||||
@ -1243,6 +1245,13 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
VolumeVO newVol = _volsDao.findById(newVolumeOnPrimaryStorage.getId());
|
VolumeVO newVol = _volsDao.findById(newVolumeOnPrimaryStorage.getId());
|
||||||
|
// Getting the fresh vm object in case of volume migration to check the current state of VM
|
||||||
|
if (moveVolumeNeeded || volumeOnSecondary) {
|
||||||
|
vm = _userVmDao.findById(vmId);
|
||||||
|
if (vm == null) {
|
||||||
|
throw new InvalidParameterValueException("VM not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
newVol = sendAttachVolumeCommand(vm, newVol, deviceId);
|
newVol = sendAttachVolumeCommand(vm, newVol, deviceId);
|
||||||
return newVol;
|
return newVol;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user