mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4379: Reset VM states when host is removed from cluster
If you shut down the agent while VMs are running, the management server assumes that the VMs are continuing to run. You can then delete the host while it is in 'disconnected' state, and those VMs will be unusable, forever in running state. They can't change state because the host no longer exists. This patch checks for any VMs that may have been tied to the removed host and resets their state so that cloudstack can continue to manage them.
This commit is contained in:
parent
9f4889a868
commit
1b52a298e8
|
|
@ -875,6 +875,15 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
// Delete the associated entries in host ref table
|
||||
_storagePoolHostDao.deletePrimaryRecordsForHost(hostId);
|
||||
|
||||
// Make sure any VMs that were marked as being on this host are cleaned up
|
||||
List<VMInstanceVO> vms = _vmDao.listByHostId(hostId);
|
||||
for (VMInstanceVO vm : vms) {
|
||||
// this is how VirtualMachineManagerImpl does it when it syncs VM states
|
||||
vm.setState(State.Stopped);
|
||||
vm.setHostId(null);
|
||||
_vmDao.persist(vm);
|
||||
}
|
||||
|
||||
// For pool ids you got, delete local storage host entries in pool table
|
||||
// where
|
||||
for (StoragePoolHostVO pool : pools) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue