Let the plugin read partner vars from the same RAM cache bash reads, so PHP and bash cannot disagree about a partner

This commit is contained in:
Gmer4Lfe
2026-08-16 19:40:49 -04:00
parent 4f95cc6d13
commit 35e59d2510
8 changed files with 25 additions and 14 deletions
+1 -1
View File
@@ -44,7 +44,7 @@
# ==============================================================================================
#
# Remote API Access — Cache-First, SSH Fallback
# If conf_sync.sh has populated /tmp/.cache/vv/d/ and
# If conf_sync.sh has populated /tmp/varaverk/conf/ and
# load_config.sh has sourced it, HOST*_<ARR>_API_KEY vars are available
# in the environment. Remote functions use them to call the arr API
# directly over Tailscale (no SSH, no remote shell). If the cached key
+1 -1
View File
@@ -10,7 +10,7 @@
# EMPTY fields, never overwrites existing values unless --overwrite is passed.
#
# After populating, pushes the updated conf to all partners via conf_sync.sh
# so they have the fresh keys in their /tmp/.cache/vv/d/ cache immediately.
# so they have the fresh keys in their /tmp/varaverk/conf/ cache immediately.
#
# ==============================================================================================
# AUTO-DETECTED FIELDS
@@ -12,7 +12,7 @@
# OPERATIONAL MODEL
# ==============================================================================================
#
# 1. conf_sync.sh --pull-only — refresh partner conf cache in RAM (/tmp/.cache/vv/d/)
# 1. conf_sync.sh --pull-only — refresh partner conf cache in RAM (/tmp/varaverk/conf/)
# 2. arr_sync.sh — sync Lidarr/Sonarr/Radarr libraries across all nodes
# 3. Rsync window (optional) — INTERMEDIATE_SYNC_SHARES, if any configured
# 4. INTERMEDIATE_MAINTENANCE_SCRIPTS — artwork fetch and any future 4-hour jobs
+12 -1
View File
@@ -729,8 +729,19 @@ function vv_disk_thresholds(): array {
// Results are cached in /tmp for 30 seconds so rapid monitor polls don't hammer remote hosts.
function vv_remote_hosts_stats(): array {
// Read ALL conf files — remote host keys live in their own host*.conf, not the current host's.
//
// The RAM cache is read first and wins, because it is the only current copy of a partner conf.
// conf_sync.sh pulls each partner's live conf into VV_CONF_RAM_CACHE_DIR; load_config.sh has
// sourced partner vars from there rather than from disk for as long as the cache has existed,
// but this glob never did — so PHP and bash could disagree about the same partner. Any
// host*.conf still sitting in CONF_DIR for a host that is not this one is a leftover from
// before sparse checkout, and is stale by definition.
$vars = vv_conf_vars();
foreach (glob(CONF_DIR . '/host*.conf') ?: [] as $f) {
$confFiles = array_merge(
glob(VV_CONF_RAM_CACHE_DIR . '/host*.conf') ?: [],
glob(CONF_DIR . '/host*.conf') ?: []
);
foreach ($confFiles as $f) {
$raw = file_get_contents($f) ?: '';
preg_match_all('/^\s*([A-Z0-9_]+)\s*=\s*["\']?([^"\'#\n]*?)["\']?\s*(?:#.*)?$/m', $raw, $m);
foreach ($m[1] as $i => $key) {
+1 -1
View File
@@ -103,7 +103,7 @@
# Reboot-surviving backup written by conf_cache_save.sh. Consumed and cleared here.
#
# CONF_RAM_CACHE_DIR
# Destination RAM cache (tmpfs, /tmp/.cache/vv/d) that load_config.sh reads
# Destination RAM cache (tmpfs, /tmp/varaverk/conf) that load_config.sh reads
# partner vars from.
#
# PARTNERSHIP_ENABLED
+1 -1
View File
@@ -93,7 +93,7 @@
# ${SCRIPTS_DIR}, so it follows the active storage mode.
#
# CONF_RAM_CACHE_DIR
# Source RAM cache (tmpfs, /tmp/.cache/vv/d) populated by conf_sync.sh.
# Source RAM cache (tmpfs, /tmp/varaverk/conf) populated by conf_sync.sh.
#
# PARTNERSHIP_ENABLED
# Checked via require_partnership().
+7 -7
View File
@@ -5,19 +5,19 @@
#
# PURPOSE
# ─────────────────────────────────────────────────────────────────────────────
# Maintains a RAM-resident conf cache at /tmp/.cache/vv/d/.
# Maintains a RAM-resident conf cache at /tmp/varaverk/conf/.
# Credentials and partner keys live in RAM only — never on disk across hosts.
#
# On array start (default / --array-start):
# 1. Copy own conf to local cache
# 2. Pull each available partner's conf from their disk → local cache
# 3. Push own conf to each available partner's /tmp/.cache/vv/d/ cache
# 3. Push own conf to each available partner's /tmp/varaverk/conf/ cache
#
# On conf save (--push-only):
# Fast path — push updated own conf to all partners' /tmp/.cache/vv/d/ only.
# Fast path — push updated own conf to all partners' /tmp/varaverk/conf/ only.
# No pulls, no local cache rebuild.
#
# Cache is /tmp/.cache/vv/d (tmpfs) — cleared every reboot, repopulated by
# Cache is /tmp/varaverk/conf (tmpfs) — cleared every reboot, repopulated by
# this script on next array start. Scripts source from cache for partner vars;
# own vars always come from disk (load_config.sh skips cached copy of own conf).
#
@@ -45,7 +45,7 @@
#
# RAM-Only Credentials
# Partner credentials and keys never touch disk on the receiving server.
# /tmp/.cache/vv/d is tmpfs — cleared every reboot. This is intentional:
# /tmp/varaverk/conf is tmpfs — cleared every reboot. This is intentional:
# partner conf files are not discoverable on disk between boots.
#
# Pull Resolves Remote Path
@@ -104,7 +104,7 @@
# Master toggle for conf syncing (default: true)
#
# CONF_RAM_CACHE_DIR
# tmpfs cache both ends read partner vars from (/tmp/.cache/vv/d). Cleared every
# tmpfs cache both ends read partner vars from (/tmp/varaverk/conf). Cleared every
# reboot, which is why conf_cache_save.sh / conf_cache_restore.sh exist.
#
# SSH_KEY
@@ -245,7 +245,7 @@ for host_var in $(compgen -v | grep -E '^HOST[0-9]+$' | sort); do
fi
fi
# ── Push: send own conf to partner's /tmp/.cache/vv/d/ cache ───────────
# ── Push: send own conf to partner's /tmp/varaverk/conf/ cache ───────────
if [[ "$PULL_ONLY" == true ]]; then
continue
fi
+1 -1
View File
@@ -173,7 +173,7 @@
fi
# ━━━ Source partner confs from /tmp cache ━━━
# conf_sync.sh pulls partner host*.conf files into /tmp/.cache/vv/d/
# conf_sync.sh pulls partner host*.conf files into /tmp/varaverk/conf/
# on array start and after any conf save. Sourcing them here makes partner vars
# (HOST2_*, HOST3_*, …) available without committing credentials to the git repo
# or violating sparse checkout — partner confs live in RAM only, cleared on reboot.