Repository navigation
Description
problem
When an HA-enabled VM stops unexpectedly while its host stays Up, the HA restart first tries the VM's last host, which is usually the host that just stopped it. If that host is Up and passes the capacity check, the VM goes straight back there. The deployment planner and vm.allocation.algorithm are never consulted.
That's the right choice when the VM itself failed, for example a guest crash. It's the wrong one when the host stopped the VM, for example when the host's kernel OOM-killed the QEMU process because the host's VMs together used more memory than it has. With memory overcommit, the capacity check counts allocated memory times the overcommit ratio, so the host that killed the VM still "has capacity". The VM is restarted on the same full host, where it, or one of its neighbours, can be killed again.
We hit this on KVM with memoryOvercommitRatio 4: Kubernetes worker VMs killed by the host's OOM killer were restarted by HA on the hosts that had killed them.
Cause:
HighAvailabilityManagerImpl.restart()starts the VM withHaTag(whenha.tagis set) andHaOperation, but never setsVirtualMachineProfile.Param.ConsiderLastHost.DeploymentPlanningManagerImpl.deployInVmLastHost()therefore tries the last host before the planner.- A successful start sets the VM's last host to the host it starts on, and a stop the VM didn't ask for doesn't change it, so the last host is the host the VM was stopped on (or, after a migration, the migration's source host).
When the host itself fails, this doesn't arise: a host that isn't Up is never used as the last host.
versions
4.22 and main. The code involved is the same on both.
The steps to reproduce the bug
- Use a KVM cluster with two or more hosts, and an HA-enabled VM running on host A.
- Kill the VM's QEMU process on A (
kill -9 <pid>), the same thing the OOM killer does. - CloudStack reports the VM stopped out of band and schedules an HA restart.
- The VM is restarted on A, even with
vm.allocation.algorithmset to an algorithm that would choose another host. The management server log showsLast host [Host {... A ...}] of VM [VM instance {...}] is UP and has enough capacity.
Reproduced on a three-host lab cluster with vm.allocation.algorithm=firstfitleastconsumed, the VM's host A being the most consumed: HA restarted it on A, with an empty host available.
What to do about it?
Changing the default would surprise people who rely on HA restarting a VM in place, so make it a setting. Add a cluster-scoped vm.ha.restart.consider.last.host, defaulting to true (today's behaviour). When it is false, the HA restart sets ConsiderLastHost=false, so the planner and allocators choose the host. The planner may still choose the same host when it is the best fit.
Activity
github-actions commentedon Nov 24, 2026
Warning
threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.
What happened
The threat detection engine failed to produce results.
Review the workflow run logs for details.
🎯 Triage report
When an HA-enabled VM stops while its host is still Up, the HA restart tries the last host first, because
restart()does not setConsiderLastHost=false. The VM can go back to the host that just killed it, for example after a host OOM kill. The reporter proposes a cluster-scoped settingvm.ha.restart.consider.last.host, defaulttrue.📊 Assessment
ConsiderLastHost=falsewhen disabled🔗 Similar issues
deployInVmLastHost()shortcut💡 Notes and suggestions
Last host ... is UP and has enough capacity.true, so existing HA behaviour is unchanged unless the setting is turned off.Add this agentic workflow to your repo
To install this agentic workflow, run