A partner's conf is in the RAM cache, not CONF_DIR, and a commented-out template entry is not configuration
This commit is contained in:
@@ -643,6 +643,30 @@ function vv_read_conf_raw(string $filename): string {
|
|||||||
return file_exists($path) ? file_get_contents($path) : '';
|
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 {
|
function vv_write_conf_raw(string $filename, string $content): bool {
|
||||||
$path = CONF_DIR . '/' . $filename;
|
$path = CONF_DIR . '/' . $filename;
|
||||||
$tmp = $path . '.vv.tmp';
|
$tmp = $path . '.vv.tmp';
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ function vv_fb_all(): array {
|
|||||||
// Read all host conf raws upfront
|
// Read all host conf raws upfront
|
||||||
$raws = [];
|
$raws = [];
|
||||||
foreach (array_keys($hosts) as $slot) {
|
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
|
// SSH key — from local host conf
|
||||||
|
|||||||
@@ -138,7 +138,15 @@ function vv_wd_bash_assoc(string $raw, string $varname): array {
|
|||||||
// declare -A VARNAME=( ["key"]=val ["key2"]=val2 )
|
// 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))
|
if (!preg_match('/^\s*declare\s+-A\s+' . preg_quote($varname, '/') . '\s*=\s*\(\s*(.*?)\s*\)/ms', $raw, $m))
|
||||||
return [];
|
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 = [];
|
$out = [];
|
||||||
foreach ($pairs[1] as $i => $k) $out[$k] = $pairs[2][$i];
|
foreach ($pairs[1] as $i => $k) $out[$k] = $pairs[2][$i];
|
||||||
return $out;
|
return $out;
|
||||||
@@ -560,7 +568,7 @@ function vv_wd_all(): array {
|
|||||||
// "No data" while HOST2's own page showed the same watchdogs reporting OK.
|
// "No data" while HOST2's own page showed the same watchdogs reporting OK.
|
||||||
$ts = vv_pt_peer_lookup($tsPeers, $hostname);
|
$ts = vv_pt_peer_lookup($tsPeers, $hostname);
|
||||||
$ip = $ts['ip'] ?? null;
|
$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');
|
$remoteApiKey = vv_wd_scalar($raw, strtoupper($slot) . '_UNRAID_API_KEY');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user