bhouse-nexthop opened a new pull request, #14777:
URL: https://github.com/apache/cloudstack/pull/14777
### Description
This PR adds an opt-in setting, `kvm.host.maintenance.run.hooks` (cluster
scope, off by default). When it is on, plain host maintenance runs the existing
rolling maintenance hook scripts. It also adds a `PostMigrate` stage that runs
once the host is empty. The PR reuses `RollingMaintenanceCommand` and
`rolling.maintenance.hooks.dir` and needs no agent change: a stage with no
script is skipped, so older agents still work.
| Path | Stage | When | On failure |
|---|---|---|---|
| prepareHostForMaintenance | PreFlight, PreMaintenance | before VMs move |
maintenance refused (also on exit 70, or if the host is not Up) |
| host reaches Maintenance | PostMigrate (new) | host is empty, runs in the
background | alert, state unchanged |
| cancelHostMaintenance | PostMaintenance | before the host is enabled again
| alert, cancel goes on |
| startRollingMaintenance | PostMigrate (new) | between entering maintenance
and the Maintenance stage | same as the Maintenance stage |
- **Maintenance stage:** plain maintenance never runs it. The operator does
that work.
- **Marker:** a host detail, `maintenance.hooks`, records the maintenance
whose PreMaintenance ran. PostMigrate and PostMaintenance only fire for that
maintenance, and PostMaintenance removes the marker.
- **Locking:** a cluster-wide lock per host is held while any stage runs,
rolling or not, so two stages never overlap on one agent.
- **Prepare checks:** the existing prepare checks run again after the hooks,
because the hooks can take minutes. If prepare then fails, PostMaintenance
undoes PreMaintenance.
- **Agent down on cancel:** cancel first restarts a disconnected agent as it
already does (`kvm.ssh.to.agent`), then waits for it. If the agent stays down,
cancel is refused while the setting is on. With the setting off, cancel goes
through without the hook.
- **No double runs:** rolling maintenance calls `maintain()` without these
hooks.
- **Docs:** the stage order is documented in the setting description and in
`agent.properties`.
Fixes: #14776
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] New feature (non-breaking change which adds functionality)
- [ ] 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
- [x] Minor
### How Has This Been Tested?
- Unit tests: `RollingMaintenanceManagerImplTest` (30) and
`ResourceManagerImplTest` (80) pass. The new cases cover:
- hooks off and on, success, failure and exit 70, host not Up, lock busy;
- PostMigrate failure and its skip cases;
- PostMaintenance running, refusing and skipping;
- cancel ordering, undo after a failed prepare, `maintain(cmd, false)`
skipping hooks, the Disabled host pre-check, and the stage order.
- Not yet run on a live KVM cluster.
#### How did you try to break this feature and the system with this change?
| Case | Result |
|---|---|
| cancel while PostMigrate runs | cancel waits for the lock; PostMigrate is
skipped if the maintenance has gone |
| PostMigrate queued across a cancel and re-prepare | skipped, because the
marker id differs |
| cancel with the agent down | agent restarted or waited for, else refused,
or skipped with the setting off |
| prepare fails after the hooks | PostMaintenance undo, or an alert if the
agent is gone |
| rolling and plain maintenance on one host | stages serialised by the lock,
and rolling skips the plain hooks |
| setting off | no hooks run; a stale marker is dropped at the next prepare |
--
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]