Fix NPE on scale VM operation after the corresponding template is deleted (#5721)

This commit is contained in:
Harikrishna 2021-12-01 10:50:43 +05:30 committed by GitHub
parent 2df82d8188
commit 895f282d9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3808,7 +3808,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (currentServiceOffering.isDynamic() && !newServiceOffering.isDynamic()) {
removeCustomOfferingDetails(vmId);
}
VMTemplateVO template = _templateDao.findById(vmForUpdate.getTemplateId());
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vmForUpdate.getTemplateId());
boolean dynamicScalingEnabled = _userVmMgr.checkIfDynamicScalingCanBeEnabled(vmForUpdate, newServiceOffering, template, vmForUpdate.getDataCenterId());
vmForUpdate.setDynamicallyScalable(dynamicScalingEnabled);
return _vmDao.update(vmId, vmForUpdate);