server: NPE may cause management server to not start (#5001)

This NPE may happen when a VM is marked removed in the DB but not its
nics on a shared network. This can usually happen due to a failed
expunged VM or when an admin manually marks a VM as removed in DB but
does not cleanup the nics/network resources.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2021-05-07 00:03:16 +05:30 committed by GitHub
parent 21b0b0f84e
commit f5e665cd63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2232,7 +2232,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId);
// only load running vms. For stopped vms get loaded on starting
if (vmInstance.getState() == State.Running) {
if (vmInstance != null && vmInstance.getState() == State.Running) {
VmAndCountDetails vmAndCount = new VmAndCountDetails(vmId, VmIpFetchTrialMax.value());
vmIdCountMap.put(nicId, vmAndCount);
}