Fix HA-enabled VMs stuck in Running after out-of-band stop (OOM-kill)#13
Open
poddm wants to merge 1 commit into
Open
Fix HA-enabled VMs stuck in Running after out-of-band stop (OOM-kill)#13poddm wants to merge 1 commit into
poddm wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes HA-enabled KVM VMs getting stuck in Running after an out-of-band stop (e.g. the QEMU process is OOM-killed while the host stays up).
Actual behaviour (before): On a power-off report,
VirtualMachineManagerImpl.handlePowerOffReportWithNoPendingJobsOnVM()calls_haMgr.scheduleRestart(vm, true). That path:advanceStop(), which submits a VM work job and blocks on it. This handler runs on theAgentManager-Handlerthread, and the VM job queue does not dispatch jobs from that context, so it blocks indefinitely.KVMInvestigator, which only checks whether the host is up — not the VM. Since the host is alive (only QEMU died), it concludes the VM is alive and exits without changing state. The VM stays Running forever and is never restarted.Expected behaviour (after): In the HA branch, the blocking
scheduleRestart()call is replaced with a direct, non-blocking path (the power-state report has already confirmed the VM is off):op_ha_workwithStep.Scheduled(guarding against a null/zerohost_idto avoid FK violations).The HA worker thread then picks up the work item on its next poll and restarts the VM on an available host.
The fix is placed in
VirtualMachineManagerImplwhere the method is defined; the runtime beanClusteredVirtualMachineManagerImplinherits it. This replaces a prior extension-side override (ATTClusteredVirtualMachineManagerImpl, removed in a companion PR) that copied the entire private handler chain to change one branch.Fixes: FLXCLD-2814
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
N/A
How Has This Been Tested?
Environment: KVM cluster on the management server with HA enabled (
ha.enabled/force.haandha.vm.restart.hostupin effect).kill -9on the QEMU PID while leaving the host UP; confirmed the VM transitions Running → Stopped and is then restarted on an available host via anop_ha_work(Step.Scheduled) item.AgentManager-Handlerthread no longer blocks while processing the power-off report (no thread stall / no backlog of power-state reports).host_idguard: when no valid last host is available, the work item is skipped (warning logged) rather than persisting a row that violates theop_ha_workFK constraint.How did you try to break this feature and the system with this change?
host_idwas already null at report time to exercise the FK-guard path.HighAvailabilityManager.Stepavoids collision with the existingItWorkVO.Stepimport).