This is an automated email from the ASF dual-hosted git repository. bhaisaab pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push: new b947eca CLOUDSTACK-9734: Destroy VM Fails sometimes (#2013) b947eca is described below commit b947eca9586d62146288e67e7fb39858d6c3328c Author: SudharmaJain <sudharma.j...@accelerite.com> AuthorDate: Sun Aug 20 18:17:28 2017 +0530 CLOUDSTACK-9734: Destroy VM Fails sometimes (#2013) --- .../com/cloud/vm/VirtualMachineManagerImpl.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java index 5127cf3..babfbdb 100755 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -1710,17 +1710,20 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac deleteVMSnapshots(vm, expunge); - // reload the vm object from db - vm = _vmDao.findByUuid(vmUuid); - try { - if (!stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) { - s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm); - throw new CloudRuntimeException("Unable to destroy " + vm); + Transaction.execute(new TransactionCallbackWithExceptionNoReturn<CloudRuntimeException>() { + public void doInTransactionWithoutResult(final TransactionStatus status) throws CloudRuntimeException { + VMInstanceVO vm = _vmDao.findByUuid(vmUuid); + try { + if (!stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) { + s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm); + throw new CloudRuntimeException("Unable to destroy " + vm); + } + } catch (final NoTransitionException e) { + s_logger.debug(e.getMessage()); + throw new CloudRuntimeException("Unable to destroy " + vm, e); + } } - } catch (final NoTransitionException e) { - s_logger.debug(e.getMessage()); - throw new CloudRuntimeException("Unable to destroy " + vm, e); - } + }); } /** -- To stop receiving notification emails like this one, please contact ['"commits@cloudstack.apache.org" <commits@cloudstack.apache.org>'].