Repository navigation
Run rolling maintenance hooks on plain host maintenance - #14777
bhouse-nexthop wants to merge 1 commit into
Conversation
Opt-in: kvm.host.maintenance.run.hooks (cluster, default false). Reuses the existing RollingMaintenanceCommand and rolling.maintenance.hooks.dir scripts on the KVM agent; no agent change. | Path | Stage | When | On failure | |---|---|---|---| | prepareHostForMaintenance | PreFlight, PreMaintenance | before VMs move | maintenance refused (also on exit 70 or host not Up) | | host reaches Maintenance | PostMigrate (new) | host is empty, runs in background | alert, state unchanged | | cancelHostMaintenance | PostMaintenance | before the host is enabled | alert, cancel goes on | - The Maintenance stage never runs on this path; the operator does the work. - Host detail `maintenance.hooks` holds an id of the maintenance whose PreMaintenance ran. PostMigrate and PostMaintenance only fire for that maintenance; PostMaintenance drops the marker. - A cluster-wide lock per host is held while any stage runs (rolling or not), so stages never overlap. - Prepare is refused before any hook when the host state can't enter maintenance (e.g. Disabled) or VMs are running with VM HA off. The usual prepare checks run again after the hooks, since they can take minutes; if prepare then fails, PostMaintenance undoes PreMaintenance. - Before PostMaintenance, cancel restarts a disconnected agent as it already does (kvm.ssh.to.agent) and waits for it; if it stays down the cancel is refused while the setting is on, and goes through without the hook once the setting is off. - A stale marker (host left maintenance some other way) is dropped when the next maintenance starts. - startRollingMaintenance gets the PostMigrate stage between entering maintenance and Maintenance, and calls maintain() without these hooks, so no stage runs twice. - Stage order documented in agent.properties. Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14777 +/- ##
============================================
+ Coverage 20.80% 20.83% +0.02%
- Complexity 20919 20962 +43
============================================
Files 6053 6053
Lines 548451 548687 +236
Branches 78719 73315 -5404
============================================
+ Hits 114128 114323 +195
- Misses 420958 420966 +8
- Partials 13365 13398 +33
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:
|
Test report: maintenance hooks on plain host maintenance (KVM)Environment
Results
Hook log (plain maintenance, then cancel) Hook log (one rolling maintenance run) Notes. Neither is caused by this PR, but both are worth knowing.
|
|
Tested the 4.22 backport of this change on a nested KVM lab running 4.22.1.1-nexthop (a 4.22.1.1-based build). The lab has 3 KVM hosts, and the hooks dir is set to
|
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 aPostMigratestage that runs once the host is empty. The PR reusesRollingMaintenanceCommandandrolling.maintenance.hooks.dirand needs no agent change: a stage with no script is skipped, so older agents still work.maintenance.hooks, records the maintenance whose PreMaintenance ran. PostMigrate and PostMaintenance only fire for that maintenance, and PostMaintenance removes the marker.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.maintain()without these hooks.agent.properties.Fixes: #14776
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
How Has This Been Tested?
RollingMaintenanceManagerImplTest(30) andResourceManagerImplTest(80) pass. The new cases cover:maintain(cmd, false)skipping hooks, the Disabled host pre-check, and the stage order.How did you try to break this feature and the system with this change?