From c441ac443a41165ad5544da7efb23012ed946d29 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Fri, 5 Jun 2026 19:44:10 -0400 Subject: [PATCH] feat: add --pull-only to conf_sync, wire into intermediate orchestrator Partner conf cache (/tmp/.vv/) was only refreshed at array start. If a partner updated their conf mid-day, this host's RAM cache went stale until next reboot. Intermediate orchestrator now pulls partner confs every 4 hours as step 1. conf_sync.sh --pull-only: pulls partner confs into local cache, skips push (push is already handled by conf_populate.sh --push-only on conf save). --- .../intermediate_sync_maintenance.sh | 29 +++++++++++++++++-- System_Essentials/conf_sync.sh | 11 ++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Orchestrators/intermediate_sync_maintenance.sh b/Orchestrators/intermediate_sync_maintenance.sh index a67215a..16646d0 100755 --- a/Orchestrators/intermediate_sync_maintenance.sh +++ b/Orchestrators/intermediate_sync_maintenance.sh @@ -6,9 +6,10 @@ # Schedule: 0 */4 * * * (every 4 hours) # # ── EXECUTION ORDER ─────────────────────────────────────────────────────────────────────────── -# 1. arr_sync.sh — sync Lidarr/Sonarr/Radarr libraries across all nodes -# 2. Rsync window (optional) — INTERMEDIATE_SYNC_SHARES, if any configured -# 3. INTERMEDIATE_MAINTENANCE_SCRIPTS — artwork fetch and any future 4-hour jobs +# 1. conf_sync.sh --pull-only — refresh partner conf cache in RAM (/tmp/.vv/) +# 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 # # ── WHY A SEPARATE ORCHESTRATOR ─────────────────────────────────────────────────────────────── # arr libraries need to converge more frequently than once a day. If a remote node adds @@ -154,6 +155,28 @@ SHARE_TIMES=() echo "" echo "━━━ $ICON_GEAR Intermediate Sync — $MY_ID — $(date '+%Y-%m-%d %H:%M:%S') ━━━" +# ============================================================================================== +# ━━━ Conf Pull ━━━ +# ============================================================================================== +echo "" +echo "━━━ $ICON_GEAR Conf Pull ━━━" + +CONF_SYNC_SCRIPT="$SCRIPTS_ROOT/System_Essentials/conf_sync.sh" +if [[ ! -f "$CONF_SYNC_SCRIPT" ]]; then + warn "conf_sync.sh not found — skipping partner conf refresh" +else + _conf_args=("--pull-only") + [[ "$DRY_RUN" == true ]] && _conf_args+=("--dry-run") + if bash "$CONF_SYNC_SCRIPT" "${_conf_args[@]}"; then + log "Partner conf cache refreshed ✅" + JOB_PASS+=("conf_sync.sh --pull-only") + else + warn "Partner conf pull failed — cache may be stale" + JOB_FAIL+=("conf_sync.sh --pull-only") + fi + unset _conf_args +fi + # ============================================================================================== # ━━━ Arr Sync ━━━ # ============================================================================================== diff --git a/System_Essentials/conf_sync.sh b/System_Essentials/conf_sync.sh index 8fb6afe..bb6e9bc 100755 --- a/System_Essentials/conf_sync.sh +++ b/System_Essentials/conf_sync.sh @@ -27,6 +27,7 @@ # # conf_sync.sh Full sync: pull from all partners + push to all partners # conf_sync.sh --push-only Push own conf to all partners (fast, for conf-save hook) +# conf_sync.sh --pull-only Pull partner confs into local cache only (for intermediate orch) # conf_sync.sh --dry-run Show what would happen, no changes # conf_sync.sh --log Verbose output # @@ -36,10 +37,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/../load_config.sh" PUSH_ONLY=false +PULL_ONLY=false FILTERED_ARGS=() for arg in "$@"; do case "$arg" in --push-only) PUSH_ONLY=true ;; + --pull-only) PULL_ONLY=true ;; *) FILTERED_ARGS+=("$arg") ;; esac done @@ -58,7 +61,7 @@ if [[ "$DRY_RUN" == false ]]; then fi # ── Copy own conf into local cache ─────────────────────────────────────────── -if [[ "$PUSH_ONLY" == false ]]; then +if [[ "$PUSH_ONLY" == false ]] && [[ "$PULL_ONLY" == false ]]; then if [[ -f "$MY_CONF" ]]; then if [[ "$DRY_RUN" == true ]]; then warn "DRY RUN — would copy $(basename "$MY_CONF") → $CACHE_DIR/" @@ -108,6 +111,10 @@ for host_var in $(compgen -v | grep -E '^HOST[0-9]+$' | sort); do fi # ── Push: send own conf to partner's /tmp/.vv/ cache ──────────────────── + if [[ "$PULL_ONLY" == true ]]; then + continue + fi + if [[ "$DRY_RUN" == true ]]; then warn "DRY RUN — would push ${MY_ID,,}.conf → $partner_host:/tmp/.vv/config/cached/.confs/" continue @@ -133,6 +140,8 @@ done # ── Summary ─────────────────────────────────────────────────────────────────── if [[ "$PUSH_ONLY" == true ]]; then info "Conf push complete — pushed to $PUSHED host(s)${FAILED:+, $FAILED failed}" +elif [[ "$PULL_ONLY" == true ]]; then + info "Conf pull complete — pulled $PULLED partner conf(s)${FAILED:+, $FAILED failed}" else info "Conf sync complete — pulled $PULLED, pushed $PUSHED${FAILED:+, $FAILED failed}" fi