bhouse-nexthop commented on PR #14777:
URL: https://github.com/apache/cloudstack/pull/14777#issuecomment-7104238699

   ### Test report: maintenance hooks on plain host maintenance (KVM)
   
   **Environment**
   - CloudStack 24.0 (main) build with this PR, plus some of my other open PRs.
   - Three KVM hosts in one cluster, Ceph RBD primary storage, one management 
server.
   - `kvm.host.maintenance.run.hooks=true` set at cluster scope. On one host, 
`rolling.maintenance.hooks.dir` pointed at a directory with trivial 
`PreFlight`, `PreMaintenance`, `PostMigrate` and `PostMaintenance` scripts. 
Each one appends a timestamp and its stage name to a log file and exits 0, 
unless a per-stage file sets the exit code. The agent uses the default systemd 
service executor.
   - A watcher sampled the host state and the number of VMs on the host every 
2-3 s.
   
   **Results**
   
   | Step | Result | Evidence |
   |---|---|---|
   | Enable maintenance with one user VM on the host | pass | hooks: PreFlight 
13:56:39, PreMaintenance 13:56:49; then `Enabled -> PrepareForMaintenance` 
13:57:00 and the VM's migration scheduled 13:57:00, done 13:57:04 |
   | PostMigrate after Maintenance is reached | pass | `PrepareForMaintenance 
-> Maintenance` 13:57:38.675, "Running maintenance hook PostMigrate" 
13:57:38.678 (background thread), finished 13:57:48 |
   | Cancel maintenance | pass | "Running maintenance hook PostMaintenance" 
13:58:01, finished 13:58:11.851; `Maintenance -> Enabled` 13:58:11.960, after 
the hook |
   | PreMaintenance exits 70 | pass | prepare fails: "Maintenance hook 
PreMaintenance on Host ... refused maintenance: ..."; host stays Up/Enabled; 
the VM on it is not migrated; PreFlight and PreMaintenance ran, nothing after 
them |
   | `startRollingMaintenance` on that host (a `Maintenance` script added for 
this run, since rolling maintenance skips a host without one) | pass | 
`success=true`, `hostsupdated=[host]`; hook log: PreFlight, PreMaintenance, 
PostMigrate, Maintenance, PostMaintenance, **once each**; no extra run from the 
plain-maintenance path |
   | PostMaintenance hook failure on cancel (by accident, see below) | pass | 
cancel waited for the stage until the stage timeout, then raised the alert 
"Maintenance hook PostMaintenance failed on host ..." and enabled the host 
anyway |
   | Cleanup | done | scripts and `rolling.maintenance.hooks.dir` removed, 
agent restarted, setting reset to false |
   
   **Hook log (plain maintenance, then cancel)**
   ```
   13:56:39.767 PreFlight rc=0
   13:56:49.918 PreMaintenance rc=0
   13:57:38.750 PostMigrate rc=0
   13:58:01.841 PostMaintenance rc=0
   ```
   
   **Hook log (one rolling maintenance run)**
   ```
   14:33:05.393 PreFlight rc=0
   14:33:15.601 PreMaintenance rc=0
   14:33:56.108 PostMigrate rc=0
   14:34:06.238 Maintenance rc=0
   14:34:16.425 PostMaintenance rc=0
   ```
   
   **Notes. Neither is caused by this PR, but both are worth knowing.**
   - My first run used a longer hooks directory 
(`/etc/cloudstack/agent/r3-hooks`). The service executor puts the stage, script 
path, timeout and both result-file paths into the systemd instance name. For 
`PostMaintenance` (the longest stage name) that name came to 256 characters, 
over systemd's 255 limit, so `systemctl start` refused it and the stage never 
ran. PreFlight, PreMaintenance and PostMigrate were under the limit and ran. 
The cancel then polled until `kvm.rolling.maintenance.stage.timeout` (1800 s), 
alerted, and enabled the host. A shorter directory 
(`/etc/cloudstack/agent/hooks`, 238 characters) fixed it. Rolling maintenance 
has the same limit; this PR just makes the PostMaintenance path more common.
   - With a user VM on the host and a single cluster, `startRollingMaintenance` 
could not migrate it. Rolling maintenance disables the cluster, and the planner 
then avoids it ("Deploy avoids clusters: [1]"), so the host ended in 
ErrorInMaintenance after 5 attempts. The rolling run above was done with the 
host empty.
   


-- 
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