fix(monitor): write Proxmox's notification settings only while /etc/pve is mounted

- Nothing is written under /etc/pve unless it is the mounted cluster
  filesystem; a Monitor that starts while pve-cluster is being restarted
  waits for it and registers its webhook afterwards.
- The Monitor service is ordered after pve-cluster.service.
- The settings are written only when they have to change. The copies
  taken before a change are kept in
  /usr/local/share/proxmenux/backups/pve-notifications, and the ones left
  in /etc/pve by earlier versions are moved there.
- Uninstalling the Monitor removes its target and matcher from Proxmox.

Reported in #427.
This commit is contained in:
MacRimi
2026-10-08 17:14:36 +02:00
parent 053b6c81f8
commit 07713d5365
10 changed files with 355 additions and 83 deletions
+17
View File
@@ -1141,6 +1141,11 @@ class NotificationManager:
wh_result = setup_pve_webhook_core()
if wh_result.get('configured'):
print("[NotificationManager] PVE webhook configured OK.")
elif wh_result.get('waiting'):
# /etc/pve is not mounted yet: nothing is written until it is.
print("[NotificationManager] PVE webhook: waiting for /etc/pve to be mounted.")
threading.Thread(target=self._configure_pve_webhook_when_mounted, daemon=True,
name='pve-webhook-setup').start()
elif wh_result.get('error'):
print(f"[NotificationManager] PVE webhook warning: {wh_result['error']}")
except ImportError:
@@ -2285,6 +2290,18 @@ class NotificationManager:
'auth_fail',
)
def _configure_pve_webhook_when_mounted(self):
"""Configure the PVE webhook once the cluster filesystem is back."""
try:
from flask_notification_routes import setup_pve_webhook_when_mounted
result = setup_pve_webhook_when_mounted()
if result.get('configured'):
print("[NotificationManager] PVE webhook configured OK.")
elif result.get('error'):
print(f"[NotificationManager] PVE webhook warning: {result['error']}")
except Exception as e:
print(f"[NotificationManager] PVE webhook setup error: {e}")
def _reset_cooldowns_on_start(self):
"""Clear DB rows in notification_last_sent for the curated set of
event types listed in `_EVENT_TYPES_RESET_ON_START`.