Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
4.4.0
-
None
-
Security Level: Public (Anyone can view this level - this is the default.)
-
None
Description
Steps to reproduce:
1) Deploy 2 vms; VM2 should be deployed with startVm=false option.
2) Stop VM1. Detach the Root disks from VM1 and VM2; attach the root disk of VM2 to VM1.
3) Try to expunge the VM1 now. NPE happens on
INFO [o.a.c.f.j.i.AsyncJobMonitor] (Work-Job-Executor-2:ctx-228bd156 job-890/job-892) Remove job-892 from job monitoring
WARN [c.c.v.UserVmManagerImpl] (UserVm-Scavenger-1:ctx-d72384e8) Unable to expunge VM[User|i-2-24-st]
java.lang.NullPointerException
at org.apache.cloudstack.engine.orchestration.VolumeOrchestrator.disconnectVolumesFromHost(VolumeOrchestrator.java:868)
at com.cloud.vm.VirtualMachineManagerImpl.advanceExpunge(VirtualMachineManagerImpl.java:528)
at com.cloud.vm.VirtualMachineManagerImpl.advanceExpunge(VirtualMachineManagerImpl.java:464)
at com.cloud.vm.UserVmManagerImpl.expunge(UserVmManagerImpl.java:1670)
at com.cloud.vm.UserVmManagerImpl.expungeVm(UserVmManagerImpl.java:3691)
NPE happens because in the code we assume that when VM has not null hostId/lastHostId (indicating it had been running at some point), then its volumes should have not null storagepoolId. This assumption is incorrect, and we should check storagePoolId of the volume first before attempting to disconnect it from the host.