bhouse-nexthop opened a new pull request, #14895: URL: https://github.com/apache/cloudstack/pull/14895
### Description When host maintenance stops a VM instead of migrating it, nothing records the stop. The owner gets no `VM.STOP` event and admins get no alert, so people find out because their workload went down. This PR adds both. When an HA `ForceStop` or a failed migration for maintenance leaves a VM Stopped that was Running (or Migrating) before: - a WARN `VM.STOP` event goes to the VM's owner: `VM <name> (<uuid>) was stopped by host maintenance` - the HA alert for the VM type goes out (`ALERT.USERVM`, router, CPVM or SSVM), with the host name added. It follows `vm.ha.alerts.enabled` like the other HA alerts. | Maintenance case | Before | After | |---|---|---| | No host available, migration not allowed, or vGPU: `ForceStop` | nothing | `VM.STOP` event + alert | | Local storage with `host.maintenance.local.storage.strategy=ForceStop` | nothing | `VM.STOP` event + alert | | Migration fails and `orchestrateMigrateAway` force-stops the VM | generic `VM.MIGRATE` error only | also `VM.STOP` event + alert | | Migration fails but the VM keeps running | `VM.MIGRATE` error | unchanged | HA work counts as maintenance if it has the `HostMaintenance` reason or its host is in a maintenance state. I left the no-host `ForceStop` untagged on purpose: tagging it `HostMaintenance` would make it cancellable after a management server restart, which would change behavior. The event and alert are best effort. A failure to record them is logged and doesn't affect the stop or the HA work. No schema change. The only file changed is `HighAvailabilityManagerImpl`. **Relation to #13189:** that PR stops `orchestrateMigrateAway` from force-stopping a VM after a failed migration and retries instead. This PR doesn't touch `VirtualMachineManagerImpl`, so the two don't conflict. With #13189 merged, the failed-migration hook simply never fires, and the two `ForceStop` cases still need this fix. Fixes: #14894 ### 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) - [ ] Build/CI - [ ] Test (unit or integration test code) ### Feature/Enhancement Scale or Bug Severity #### Feature/Enhancement Scale - [ ] Major - [ ] Minor #### Bug Severity - [ ] BLOCKER - [ ] Critical - [ ] Major - [x] Minor - [ ] Trivial ### Screenshots (if appropriate): ### How Has This Been Tested? Unit tests in `HighAvailabilityManagerImplTest`: - `ForceStop` and a failed migration both check for a maintenance stop. A `ForceStop` that fails records nothing. - A stop tagged `HostMaintenance` writes the event against the owner account and sends the alert. - A stop with no tag on a host in `PrepareForMaintenance` is recorded. On an `Enabled` host it isn't. - Nothing is recorded if the VM is still running, or wasn't running before the attempt. - A DB error while recording doesn't escape. The full `server` module test suite passes. #### How did you try to break this feature and the system with this change? - VMs already Stopping or Starting when maintenance began are not reported as stopped by maintenance. - The event text leaves out the hypervisor host name, because the VM owner can see it. Only the admin alert names the host. - Hidden VMs (`displayvm=false`) get a hidden event. Not done here: - SSVM/CPVM destroyed by maintenance (they're recreated automatically). - The LXC restart path, which already alerts when the restart fails. -- 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]
