Fix 13785 vm ha error state - #13808
Conversation
Co-authored-by: Gean Jair Silva <gean.silva@scclouds.com.br>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13808 +/- ##
=========================================
Coverage 19.65% 19.65%
+ Complexity 19792 19791 -1
=========================================
Files 6368 6368
Lines 574881 574887 +6
Branches 70351 70353 +2
=========================================
+ Hits 112970 112974 +4
+ Misses 449639 449638 -1
- Partials 12272 12275 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@Dogface2k , you are fixing on main, but the bug is reported in 4.20. Can you rebase on that branch? We will merge forwards all fixes on older versions (i.e to 22 and main…) |
Being resolved, agents new environment didn't check the head it was suppose to be building from. |
0115c1f to
03006c2
Compare
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/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.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.The final branch diff was audited against Apache
main: it contains only the HA implementation change and its regression tests—two files, 39 additions and no unrelated files.Upstream GitHub Actions checks are currently waiting for maintainer approval, so no passing CI result is claimed in this description.
How did you try to break this feature and the system with this change?
ErrorVM.scheduleRestart(...)call site. Callers that already restrict execution toStarting,RunningorStoppingremain unchanged; the central guard covers the unfinished-work path that can pass a VM whose current state has already becomeError.ForceHA, valid-state host recovery, migration timeout recovery, host maintenance/degraded handling and out-of-band stop recovery unchanged.