jmsperu opened a new pull request, #14919:
URL: https://github.com/apache/cloudstack/pull/14919

   ### Description
   
   Fixes: #14840
   
   When an HA attempt ends with an unchecked exception (for example a 
`CloudRuntimeException` from the start of the VM), the generic `catch` in 
`HighAvailabilityManagerImpl.processWork()` stores the update count and state 
of the VM object that was read before the attempt. The attempt has already 
changed the VM, so these values are stale. On the next attempt `restart()` 
compares `vm.getUpdated()` with `work.getUpdateTime()`, decides that the VM was 
changed by someone else and returns `null`, and `processWork()` marks the work 
as `Done`. The VM stays stopped and the remaining retries are never used.
   
   This PR reads the VM again in that `catch` block before recording its update 
count and state, which is what `restart()` itself already does on its handled 
failure paths.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [x] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [x] Major
   - [ ] Minor
   - [ ] Trivial
   
   ### How Has This Been Tested?
   
   New unit test 
`HighAvailabilityManagerImplTest.processWorkRecordsCurrentVmStateWhenRestartThrows`:
 `restart()` throws a `CloudRuntimeException` and the VM read after the attempt 
has a new update count and state. The test checks that the work stays scheduled 
and carries the new values.
   
   - With the fix: `Tests run: 23, Failures: 0, Errors: 0`
   - Without the fix: the new test fails with `expected:<20> but was:<0>`
   
   Not tested on a live HA failure.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to