feat(cm): auto-open Kuma maintenance windows on rollback (OQ5 YES) [#769]

kuma-maintenance.py (open/list/delete, single-strategy windows,
version-tolerant addMaintenance probing) + pve-snapshot.sh rollback
opens a 30m window before touching a VM when ~/.creds/uptime-kuma.env
exists. TZ pinned America/Chicago. Verified: open->list(active=True)->
delete live on the fleet Kuma.

https://projects.knownelement.com/issues/769#note-4152
This commit is contained in:
2026-09-04 06:05:27 -05:00
parent ce55409b9a
commit 66def2e311
2 changed files with 174 additions and 0 deletions
+12
View File
@@ -96,6 +96,18 @@ rollback)
done
guard_protected "$vmid" "rollback" "$force"
[ -n "$yes" ] || die "rollback STOPS the VM. Set an Uptime Kuma maintenance window for monitored VMs, then pass --yes"
# OQ5 approved (questions-v10): auto-open a Kuma window when creds exist.
if [ -f "$HOME/.creds/uptime-kuma.env" ]; then
win="$(timeout 240 docker run --rm -v "$SCRIPT_DIR/..:/app" -w /app \
--env-file "$HOME/.creds/uptime-kuma.env" -e TZ=America/Chicago \
python:3.12-slim sh -c 'pip install -q --no-cache-dir "python-socketio[client]" websocket-client >/dev/null 2>&1; python3 scripts/kuma-maintenance.py open --title "cm rollback vmid='"$vmid"'" --minutes 30 --desc "pve-snapshot.sh '"$snap"'"' 2>/dev/null \
| grep -o 'id=[0-9]*' | head -1 | cut -d= -f2 || true)"
if [ -n "$win" ]; then
log "Kuma maintenance window id=$win opened (30m)"
else
log "WARN: could not open Kuma window (creds present) — create it manually before proceeding"
fi
fi
log "rolling back $vmid to $snap (VM will be stopped)"
prox "qm rollback $vmid '$snap'"
log_action "rollback vmid=$vmid snap=$snap"