From 95fa2440ce8a6de9aa4d2526d21730e6b147d4a9 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Sat, 28 Feb 2026 17:18:03 +0100 Subject: [PATCH] Update notification service --- AppImage/components/health-status-modal.tsx | 2 +- AppImage/scripts/flask_health_routes.py | 9 ++++----- AppImage/scripts/health_monitor.py | 12 ++++++++---- AppImage/scripts/health_persistence.py | 10 ++++++---- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/AppImage/components/health-status-modal.tsx b/AppImage/components/health-status-modal.tsx index 7102d760..a43cd720 100644 --- a/AppImage/components/health-status-modal.tsx +++ b/AppImage/components/health-status-modal.tsx @@ -3,7 +3,7 @@ import type React from "react" import { useState, useEffect, useCallback } from "react" -import { fetchApi, getApiUrl, getAuthToken } from "@/lib/api-config" +import { getAuthToken } from "@/lib/api-config" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" diff --git a/AppImage/scripts/flask_health_routes.py b/AppImage/scripts/flask_health_routes.py index 5113daf2..1d5c933f 100644 --- a/AppImage/scripts/flask_health_routes.py +++ b/AppImage/scripts/flask_health_routes.py @@ -83,11 +83,10 @@ def acknowledge_error(): health_monitor.last_check_times.pop(cache_key, None) health_monitor.cached_results.pop(cache_key, None) - # Also invalidate overall status caches so header updates immediately - health_monitor.last_check_times.pop('_bg_overall', None) - health_monitor.cached_results.pop('_bg_overall', None) - health_monitor.last_check_times.pop('overall_health', None) - health_monitor.cached_results.pop('overall_health', None) + # Also invalidate ALL background/overall caches so next fetch reflects dismiss + for ck in ['_bg_overall', '_bg_detailed', 'overall_health']: + health_monitor.last_check_times.pop(ck, None) + health_monitor.cached_results.pop(ck, None) # Use the per-record suppression hours from acknowledge_error() sup_hours = result.get('suppression_hours', 24) diff --git a/AppImage/scripts/health_monitor.py b/AppImage/scripts/health_monitor.py index 6bc45463..75295442 100644 --- a/AppImage/scripts/health_monitor.py +++ b/AppImage/scripts/health_monitor.py @@ -2248,24 +2248,28 @@ class HealthMonitor: 'status': _log_check_status('log_error_cascade', cascade_count > 0, 'WARNING'), 'detail': f'{cascade_count} pattern(s) repeating >=15 times' if cascade_count > 0 else 'No cascading errors', 'dismissable': True, - 'dismissed': 'log_error_cascade' in dismissed_keys + 'dismissed': 'log_error_cascade' in dismissed_keys, + 'error_key': 'log_error_cascade' }, 'log_error_spike': { 'status': _log_check_status('log_error_spike', spike_count > 0, 'WARNING'), 'detail': f'{spike_count} pattern(s) with 4x increase' if spike_count > 0 else 'No error spikes', 'dismissable': True, - 'dismissed': 'log_error_spike' in dismissed_keys + 'dismissed': 'log_error_spike' in dismissed_keys, + 'error_key': 'log_error_spike' }, 'log_persistent_errors': { 'status': _log_check_status('log_persistent_errors', persistent_count > 0, 'WARNING'), 'detail': f'{persistent_count} recurring pattern(s) over 15+ min' if persistent_count > 0 else 'No persistent patterns', 'dismissable': True, - 'dismissed': 'log_persistent_errors' in dismissed_keys + 'dismissed': 'log_persistent_errors' in dismissed_keys, + 'error_key': 'log_persistent_errors' }, 'log_critical_errors': { 'status': _log_check_status('log_critical_errors', unique_critical_count > 0, 'CRITICAL'), 'detail': f'{unique_critical_count} critical error(s) found' if unique_critical_count > 0 else 'No critical errors', - 'dismissable': False + 'dismissable': False, + 'error_key': 'log_critical_errors' } } diff --git a/AppImage/scripts/health_persistence.py b/AppImage/scripts/health_persistence.py index fa465e00..4d4ae3d2 100644 --- a/AppImage/scripts/health_persistence.py +++ b/AppImage/scripts/health_persistence.py @@ -414,13 +414,15 @@ class HealthPersistence: # Error not in DB yet -- create a minimal record so the dismiss persists. # Try to infer category from the error_key prefix. category = '' - for cat, prefix in [('security', 'security_'), ('updates', 'security_updates'), - ('updates', 'update_'), ('updates', 'kernel_'), - ('updates', 'pending_'), ('updates', 'system_age'), + # Order matters: more specific prefixes MUST come before shorter ones + # e.g. 'security_updates' (updates) before 'security_' (security) + for cat, prefix in [('updates', 'security_updates'), ('updates', 'system_age'), + ('updates', 'pending_updates'), ('updates', 'kernel_pve'), + ('security', 'security_'), ('pve_services', 'pve_service_'), ('vms', 'vm_'), ('vms', 'ct_'), ('disks', 'disk_'), ('logs', 'log_'), ('network', 'net_'), ('temperature', 'temp_')]: - if error_key.startswith(prefix) or error_key == prefix: + if error_key == prefix or error_key.startswith(prefix): category = cat break