From 13c221244e51142c286bd8c42a6e23a84ba996d4 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Sat, 22 Aug 2026 01:06:24 -0400 Subject: [PATCH] A partner's conf is in the RAM cache, not CONF_DIR, and a commented-out template entry is not configuration --- Plugin/unraid/include/config.php | 24 ++++++++++++++++++++++++ Plugin/unraid/include/fallback.php | 2 +- Plugin/unraid/include/watchdog.php | 12 ++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Plugin/unraid/include/config.php b/Plugin/unraid/include/config.php index 9b239ee..21b8603 100644 --- a/Plugin/unraid/include/config.php +++ b/Plugin/unraid/include/config.php @@ -643,6 +643,30 @@ function vv_read_conf_raw(string $filename): string { return file_exists($path) ? file_get_contents($path) : ''; } + +// Read one HOST's conf, wherever that host's conf actually lives for this reader. +// +// Sparse checkout means a host only ever checks out its OWN host*.conf, so on HOST1 the file +// Configurations/host2.conf does not exist and never will. vv_read_conf_raw() looks only in +// CONF_DIR, so every caller that passed it a partner's slot silently got an empty string — and +// an empty conf parses into empty arrays, which render as "none". The Watchdog tab showed the +// partner's memory limits, required list, pause list, stop list and scan-ignore list as five +// empty sections, and the Fallback tab reported the partner's tiers as unconfigured, on a mesh +// where conf_sync had been delivering all of it into the RAM cache the whole time. +// +// Partner confs are pulled into VV_CONF_RAM_CACHE_DIR by System_Essentials/conf_sync.sh. Disk +// first for this host, RAM cache for anyone else; the disk copy is never preferred for a +// partner, because a stale Configurations/host2.conf left behind by an old install is exactly +// the file that must not win. An absent cache returns empty, same as before. +function vv_read_host_conf_raw(string $slot): string { + $slot = strtolower($slot); + if ($slot === vv_detect_host()) return vv_read_conf_raw($slot . '.conf'); + + $cached = rtrim(VV_CONF_RAM_CACHE_DIR, '/') . '/' . $slot . '.conf'; + if (is_readable($cached)) return (string)@file_get_contents($cached); + + return ''; +} function vv_write_conf_raw(string $filename, string $content): bool { $path = CONF_DIR . '/' . $filename; $tmp = $path . '.vv.tmp'; diff --git a/Plugin/unraid/include/fallback.php b/Plugin/unraid/include/fallback.php index 6493d47..db7a612 100644 --- a/Plugin/unraid/include/fallback.php +++ b/Plugin/unraid/include/fallback.php @@ -237,7 +237,7 @@ function vv_fb_all(): array { // Read all host conf raws upfront $raws = []; foreach (array_keys($hosts) as $slot) { - $raws[$slot] = vv_read_conf_raw($slot . '.conf'); + $raws[$slot] = vv_read_host_conf_raw($slot); // partner conf lives in the RAM cache, not CONF_DIR } // SSH key — from local host conf diff --git a/Plugin/unraid/include/watchdog.php b/Plugin/unraid/include/watchdog.php index 31062e6..739e968 100644 --- a/Plugin/unraid/include/watchdog.php +++ b/Plugin/unraid/include/watchdog.php @@ -138,7 +138,15 @@ function vv_wd_bash_assoc(string $raw, string $varname): array { // declare -A VARNAME=( ["key"]=val ["key2"]=val2 ) if (!preg_match('/^\s*declare\s+-A\s+' . preg_quote($varname, '/') . '\s*=\s*\(\s*(.*?)\s*\)/ms', $raw, $m)) return []; - preg_match_all('/\["([^"]+)"\]\s*=\s*"?([^"\s\)]*)"?/', $m[1], $pairs); + // Strip comments before matching, from # to end of line. Without this a commented-out + // template entry — `# ["Emby"]=18432`, which is how every host*.conf ships — parses as a + // live memory limit. It never showed on this host because this host's entries are real; it + // appeared the moment a PARTNER's conf became readable and its whole commented block was + // read as configuration. Cut per line, so a trailing comment on a real entry still keeps it: + // `["Emby"]=24576 # 24GB — raised 2026-07-11` must survive. vv_parse_bash_array(), which + // the list form delegates to, has always done this. + $body = preg_replace('/#.*$/m', '', $m[1]); + preg_match_all('/\["([^"]+)"\]\s*=\s*"?([^"\s\)]*)"?/', $body, $pairs); $out = []; foreach ($pairs[1] as $i => $k) $out[$k] = $pairs[2][$i]; return $out; @@ -560,7 +568,7 @@ function vv_wd_all(): array { // "No data" while HOST2's own page showed the same watchdogs reporting OK. $ts = vv_pt_peer_lookup($tsPeers, $hostname); $ip = $ts['ip'] ?? null; - $raw = vv_read_conf_raw($slot . '.conf'); + $raw = vv_read_host_conf_raw($slot); // partner conf lives in the RAM cache, not CONF_DIR $remoteApiKey = vv_wd_scalar($raw, strtoupper($slot) . '_UNRAID_API_KEY');