server: skip HA restart for VMs in Error state - #13811
Open
Dogface2k wants to merge 1 commit into
Open
Conversation
Dogface2k
marked this pull request as draft
August 6, 2026 10:05
Dogface2k
marked this pull request as ready for review
August 6, 2026 10:13
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
Fixes #13785.
Problem
When deployment of an HA-enabled VM fails, the VM can be left in
Errorstate. CloudStack could subsequently pass that VM toHighAvailabilityManagerImpl.scheduleRestart(...)and create HA work for it. If the work item was created while the VM was already inError, the worker's existing state and update checks still matched and HA processing could continue into host investigation, fencing, forced-stop, storage and restart handling.This is inconsistent with the VM lifecycle:
Errorrepresents a failed or inconsistent VM state and there is no normal start transition fromError.Root cause
The shared HA restart entry point did not reject VMs in
Errorstate, and the HA worker did not independently reject an already-persisted work item when the current VM state wasError.Change
This PR enforces the lifecycle invariant at both boundaries:
scheduleRestart(...)returns before any HA work, forced stop, orchestration or alert side effect is attempted for anError-state VM.restart(...)treats an already-queued HA restart for anError-state VM as complete before host investigation, fencing, storage checks or VM start handling.The execution-time check also covers work persisted before an upgrade and the race where a VM enters
Errorafter scheduling but before the HA worker processes it.The change deliberately does not make
Errorstartable, rewrite the VM state, suppress an exception after the operation has begun, or alter HA behaviour for valid VM states. There are no API, database, configuration or UI changes.The branch is based directly on the current
4.20head so that the fix can be merged forward into later release branches.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate)
Not applicable; this is management-server HA behaviour with no UI change.
How Has This Been Tested?
Focused regression tests were added to
HighAvailabilityManagerImplTest:scheduleRestartVMInErrorStateverifies that anError-state VM cannot create HA work or invoke orchestration or alert side effects.restartVMInErrorStateverifies that already-queued work returns without host lookup, alerting, user-VM start handling, volume restart checks or direct work-step mutation.restartVMNotInErrorStateContinuesProcessingverifies that the new worker guard does not stop normal processing for a valid non-ErrorVM state.The final branch diff was audited against the current Apache
4.20head. It contains one commit and changes only the HA implementation and its regression test class: two files, 58 additions and no deletions.The upstream checks must rerun after the rebase, so no new passing CI result is claimed here yet.
How did you try to break this feature and the system with this change?
ErrorVM.ErrorVM.scheduleRestart(...)call paths and retained all valid-state HA behaviour.ForceHA, valid-state host recovery, migration timeout recovery, host maintenance/degraded handling and out-of-band stop recovery unchanged.