mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-18 10:02:16 +00:00
Update health_persistence.py
This commit is contained in:
@@ -868,6 +868,7 @@ class HealthPersistence:
|
|||||||
return self._cleanup_old_errors_impl()
|
return self._cleanup_old_errors_impl()
|
||||||
|
|
||||||
def _cleanup_old_errors_impl(self):
|
def _cleanup_old_errors_impl(self):
|
||||||
|
print("[HealthPersistence] Running cleanup_old_errors...")
|
||||||
conn = self._get_conn()
|
conn = self._get_conn()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
@@ -968,6 +969,8 @@ class HealthPersistence:
|
|||||||
''')
|
''')
|
||||||
active_errors = cursor.fetchall()
|
active_errors = cursor.fetchall()
|
||||||
|
|
||||||
|
print(f"[HealthPersistence] _cleanup_stale_resources: Found {len(active_errors)} active errors to check")
|
||||||
|
|
||||||
resolved_count = 0
|
resolved_count = 0
|
||||||
|
|
||||||
# Cache for expensive checks (avoid repeated subprocess calls)
|
# Cache for expensive checks (avoid repeated subprocess calls)
|
||||||
@@ -1083,9 +1086,13 @@ class HealthPersistence:
|
|||||||
# Check if VM/CT still exists (covers: vms/vmct categories, vm_*, ct_*, vmct_* error keys)
|
# Check if VM/CT still exists (covers: vms/vmct categories, vm_*, ct_*, vmct_* error keys)
|
||||||
if category in ('vms', 'vmct') or (error_key and (error_key.startswith('vm_') or error_key.startswith('ct_') or error_key.startswith('vmct_'))):
|
if category in ('vms', 'vmct') or (error_key and (error_key.startswith('vm_') or error_key.startswith('ct_') or error_key.startswith('vmct_'))):
|
||||||
vmid = extract_vmid_from_text(error_key) or extract_vmid_from_text(reason)
|
vmid = extract_vmid_from_text(error_key) or extract_vmid_from_text(reason)
|
||||||
if vmid and not check_vm_ct_cached(vmid):
|
print(f"[HealthPersistence] Checking VM/CT error: key={error_key}, category={category}, vmid={vmid}")
|
||||||
should_resolve = True
|
if vmid:
|
||||||
resolution_reason = 'VM/CT deleted'
|
exists = check_vm_ct_cached(vmid)
|
||||||
|
print(f"[HealthPersistence] VM/CT {vmid} exists: {exists}")
|
||||||
|
if not exists:
|
||||||
|
should_resolve = True
|
||||||
|
resolution_reason = 'VM/CT deleted'
|
||||||
|
|
||||||
# === DISK ERRORS ===
|
# === DISK ERRORS ===
|
||||||
# Check if disk device or ZFS pool still exists
|
# Check if disk device or ZFS pool still exists
|
||||||
@@ -1200,10 +1207,11 @@ class HealthPersistence:
|
|||||||
resolution_reason = 'Stale error (no activity >7d)'
|
resolution_reason = 'Stale error (no activity >7d)'
|
||||||
|
|
||||||
if should_resolve:
|
if should_resolve:
|
||||||
|
print(f"[HealthPersistence] Resolving error: {error_key} - {resolution_reason}")
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
UPDATE errors SET resolved_at = ?, resolution_type = 'auto'
|
UPDATE errors SET resolved_at = ?, resolution_type = 'auto', resolution_reason = ?
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
''', (now_iso, err_id))
|
''', (now_iso, resolution_reason, err_id))
|
||||||
resolved_count += 1
|
resolved_count += 1
|
||||||
|
|
||||||
if resolved_count > 0:
|
if resolved_count > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user