From 6f8503315865cb52e724be129568277301abe7f0 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Wed, 20 Nov 2024 10:47:51 +0100 Subject: [PATCH 1/2] get expunged VM data for job result --- server/src/main/java/com/cloud/vm/UserVmManagerImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index 9d5a1be894b9..ed10a55da239 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -5569,7 +5569,7 @@ private Host getDestinationHost(Long hostId, boolean isRootAdmin, boolean isExpl @Override public UserVm destroyVm(long vmId, boolean expunge) throws ResourceUnavailableException, ConcurrentOperationException { // Verify input parameters - UserVmVO vm = _vmDao.findById(vmId); + UserVmVO vm = _vmDao.findByIdIncludingRemoved(vmId); if (vm == null || vm.getRemoved() != null) { InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a virtual machine with specified vmId"); throw ex; @@ -5611,7 +5611,7 @@ public UserVm destroyVm(long vmId, boolean expunge) throws ResourceUnavailableEx //Update Resource Count for the given account resourceCountDecrement(vm.getAccountId(), vm.isDisplayVm(), new Long(offering.getCpu()), new Long(offering.getRamSize())); } - return _vmDao.findById(vmId); + return _vmDao.findByIdIncludingRemoved(vmId); } else { CloudRuntimeException ex = new CloudRuntimeException("Failed to destroy vm with specified vmId"); ex.addProxyObject(vm.getUuid(), "vmId"); From a37dc981d38b792927a2c6b5657d73eef6b55a17 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Wed, 20 Nov 2024 15:20:21 +0100 Subject: [PATCH 2/2] only find including removed after destroy --- server/src/main/java/com/cloud/vm/UserVmManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index ed10a55da239..6e75512948a3 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -5569,7 +5569,7 @@ private Host getDestinationHost(Long hostId, boolean isRootAdmin, boolean isExpl @Override public UserVm destroyVm(long vmId, boolean expunge) throws ResourceUnavailableException, ConcurrentOperationException { // Verify input parameters - UserVmVO vm = _vmDao.findByIdIncludingRemoved(vmId); + UserVmVO vm = _vmDao.findById(vmId); if (vm == null || vm.getRemoved() != null) { InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a virtual machine with specified vmId"); throw ex;