From c97e3b286c16d2de098fb6572f57eb1771d60d86 Mon Sep 17 00:00:00 2001 From: Oleksandr Berezovskyi Date: Sat, 9 May 2026 11:38:11 +0300 Subject: [PATCH] fix(k8s/archmirror): two-pass rsync to prevent db/package 404 race --- kubernetes/app/archmirror/configmap-sync.yaml | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/kubernetes/app/archmirror/configmap-sync.yaml b/kubernetes/app/archmirror/configmap-sync.yaml index c08a06c..1ab561a 100644 --- a/kubernetes/app/archmirror/configmap-sync.yaml +++ b/kubernetes/app/archmirror/configmap-sync.yaml @@ -22,13 +22,26 @@ data: fi mkdir -p "$TARGET_DIR" + + do_rsync() { + rsync --timeout=600 \ + -rltH --no-perms --chmod=D755,F664 --safe-links --delete-delay --delay-updates \ + -v --info=progress2 \ + "$@" + } + for i in $(seq 1 $MAX_RETRIES); do log "Sync attempt $i/$MAX_RETRIES from $MIRROR_URL" - if rsync --timeout=600 \ - -rltH --no-perms --chmod=D755,F664 --safe-links --delete-delay --delay-updates \ - -v --info=progress2 \ - "$MIRROR_URL/" "$TARGET_DIR/"; then + # Pass 1: sync packages, skip db/files indices so they are never updated + # before their referenced package files arrive (avoids 404s). + # Pass 2: sync everything including indices now that packages are present. + if do_rsync \ + --exclude='*.db' --exclude='*.db.*' \ + --exclude='*.files' --exclude='*.files.*' \ + "$MIRROR_URL/" "$TARGET_DIR/" \ + && do_rsync \ + "$MIRROR_URL/" "$TARGET_DIR/"; then log "Sync completed successfully" exit 0 fi