Add timed mutes so a temporary problem stops needing a permanent exemption

Every existing exemption lasts until someone remembers to undo it, and nobody
does — Healarr has sat in a pressure list since it was uninstalled and seven
ignore entries name containers that are gone. A mute states when it ends and
then ends, capped by WATCHDOG_MUTE_MAX_HOURS so temporary is enforced rather
than intended. Applied where IGNORE_MAP is built, so all five check sites
inherit it, and shown with its countdown because an invisible suppression is
the thing being fixed.
This commit is contained in:
Gmer4Lfe
2026-08-14 16:28:59 -04:00
parent 9f32644c32
commit 2cd1384786
5 changed files with 204 additions and 0 deletions
+26
View File
@@ -84,6 +84,31 @@ function vv_wd_installed_containers(): array {
return array_values(array_filter(array_map('trim', $out), fn($n) => $n !== ''));
}
// Active timed mutes, as [name => ['left' => seconds, 'reason' => text]]. Expiry is a read-time
// comparison here for the same reason it is in wd_mute_active(): a mute ends when it says it does,
// whether or not anything has pruned the file since.
//
// Surfaced because a suppression nobody can see is the problem this feature exists to fix. An
// invisible exemption gets forgotten exactly like a permanent one — the only difference would be
// that this one also lies about how long it lasts.
function vv_wd_mutes(string $file = ''): array {
$path = $file ?: (vv_conf_vars()['WATCHDOG_MUTE_FILE'] ?? STATE_DIR . '/watchdog_mutes.db');
$raw = @file_get_contents($path);
if ($raw === false) return [];
$now = time();
$out = [];
foreach (explode("\n", $raw) as $line) {
$line = trim($line);
if ($line === '') continue;
$p = explode('|', $line);
if (count($p) < 2) continue;
$until = (int)$p[1];
if ($until <= $now || $p[0] === '') continue;
$out[$p[0]] = ['left' => $until - $now, 'reason' => trim($p[2] ?? '')];
}
return $out;
}
// How many minutes are supposed to pass between watchdog cycles.
//
// Parsed from varaverk.cron, which the scheduler regenerates at array start and is the only place
@@ -294,6 +319,7 @@ function vv_wd_local_states(string $restartLogPath): array {
// The heartbeat, not a strike — see VV_WD_SYS_BOOKKEEPING. stability_watchdog.sh writes it
// last in the chain, so a fresh value means a whole cycle completed rather than started.
'last_cycle' => (int)($sys['watchdog_cycle'] ?? 0),
'mutes' => vv_wd_mutes(),
'reboots' => vv_wd_parse_reboot_log($rebootRaw),
'restarts' => vv_wd_parse_restart_log($restartRaw),
'storage_wd' => vv_wd_parse_storage_state($storRaw) + [