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:
@@ -44,7 +44,7 @@
|
|||||||
# ==============================================================================================
|
# ==============================================================================================
|
||||||
#
|
#
|
||||||
# Remote API Access — Cache-First, SSH Fallback
|
# 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
|
# 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
|
# in the environment. Remote functions use them to call the arr API
|
||||||
# directly over Tailscale (no SSH, no remote shell). If the cached key
|
# directly over Tailscale (no SSH, no remote shell). If the cached key
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
# EMPTY fields, never overwrites existing values unless --overwrite is passed.
|
# EMPTY fields, never overwrites existing values unless --overwrite is passed.
|
||||||
#
|
#
|
||||||
# After populating, pushes the updated conf to all partners via conf_sync.sh
|
# 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
|
# AUTO-DETECTED FIELDS
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
# OPERATIONAL MODEL
|
# 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
|
# 2. arr_sync.sh — sync Lidarr/Sonarr/Radarr libraries across all nodes
|
||||||
# 3. Rsync window (optional) — INTERMEDIATE_SYNC_SHARES, if any configured
|
# 3. Rsync window (optional) — INTERMEDIATE_SYNC_SHARES, if any configured
|
||||||
# 4. INTERMEDIATE_MAINTENANCE_SCRIPTS — artwork fetch and any future 4-hour jobs
|
# 4. INTERMEDIATE_MAINTENANCE_SCRIPTS — artwork fetch and any future 4-hour jobs
|
||||||
|
|||||||
@@ -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.
|
// Results are cached in /tmp for 30 seconds so rapid monitor polls don't hammer remote hosts.
|
||||||
function vv_remote_hosts_stats(): array {
|
function vv_remote_hosts_stats(): array {
|
||||||
// Read ALL conf files — remote host keys live in their own host*.conf, not the current host's.
|
// 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();
|
$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) ?: '';
|
$raw = file_get_contents($f) ?: '';
|
||||||
preg_match_all('/^\s*([A-Z0-9_]+)\s*=\s*["\']?([^"\'#\n]*?)["\']?\s*(?:#.*)?$/m', $raw, $m);
|
preg_match_all('/^\s*([A-Z0-9_]+)\s*=\s*["\']?([^"\'#\n]*?)["\']?\s*(?:#.*)?$/m', $raw, $m);
|
||||||
foreach ($m[1] as $i => $key) {
|
foreach ($m[1] as $i => $key) {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
# Reboot-surviving backup written by conf_cache_save.sh. Consumed and cleared here.
|
# Reboot-surviving backup written by conf_cache_save.sh. Consumed and cleared here.
|
||||||
#
|
#
|
||||||
# CONF_RAM_CACHE_DIR
|
# 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.
|
# partner vars from.
|
||||||
#
|
#
|
||||||
# PARTNERSHIP_ENABLED
|
# PARTNERSHIP_ENABLED
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
# ${SCRIPTS_DIR}, so it follows the active storage mode.
|
# ${SCRIPTS_DIR}, so it follows the active storage mode.
|
||||||
#
|
#
|
||||||
# CONF_RAM_CACHE_DIR
|
# 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
|
# PARTNERSHIP_ENABLED
|
||||||
# Checked via require_partnership().
|
# Checked via require_partnership().
|
||||||
|
|||||||
@@ -5,19 +5,19 @@
|
|||||||
#
|
#
|
||||||
# PURPOSE
|
# 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.
|
# Credentials and partner keys live in RAM only — never on disk across hosts.
|
||||||
#
|
#
|
||||||
# On array start (default / --array-start):
|
# On array start (default / --array-start):
|
||||||
# 1. Copy own conf to local cache
|
# 1. Copy own conf to local cache
|
||||||
# 2. Pull each available partner's conf from their disk → 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):
|
# 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.
|
# 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;
|
# 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).
|
# own vars always come from disk (load_config.sh skips cached copy of own conf).
|
||||||
#
|
#
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
#
|
#
|
||||||
# RAM-Only Credentials
|
# RAM-Only Credentials
|
||||||
# Partner credentials and keys never touch disk on the receiving server.
|
# 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.
|
# partner conf files are not discoverable on disk between boots.
|
||||||
#
|
#
|
||||||
# Pull Resolves Remote Path
|
# Pull Resolves Remote Path
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
# Master toggle for conf syncing (default: true)
|
# Master toggle for conf syncing (default: true)
|
||||||
#
|
#
|
||||||
# CONF_RAM_CACHE_DIR
|
# 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.
|
# reboot, which is why conf_cache_save.sh / conf_cache_restore.sh exist.
|
||||||
#
|
#
|
||||||
# SSH_KEY
|
# SSH_KEY
|
||||||
@@ -245,7 +245,7 @@ for host_var in $(compgen -v | grep -E '^HOST[0-9]+$' | sort); do
|
|||||||
fi
|
fi
|
||||||
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
|
if [[ "$PULL_ONLY" == true ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|||||||
+1
-1
@@ -173,7 +173,7 @@
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ━━━ Source partner confs from /tmp cache ━━━
|
# ━━━ 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
|
# on array start and after any conf save. Sourcing them here makes partner vars
|
||||||
# (HOST2_*, HOST3_*, …) available without committing credentials to the git repo
|
# (HOST2_*, HOST3_*, …) available without committing credentials to the git repo
|
||||||
# or violating sparse checkout — partner confs live in RAM only, cleared on reboot.
|
# or violating sparse checkout — partner confs live in RAM only, cleared on reboot.
|
||||||
|
|||||||
Reference in New Issue
Block a user