fix(k8s/archmirror): two-pass rsync to prevent db/package 404 race

This commit is contained in:
2026-05-09 11:38:11 +03:00
parent 23e748b699
commit c97e3b286c
+17 -4
View File
@@ -22,13 +22,26 @@ data:
fi fi
mkdir -p "$TARGET_DIR" 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 for i in $(seq 1 $MAX_RETRIES); do
log "Sync attempt $i/$MAX_RETRIES from $MIRROR_URL" log "Sync attempt $i/$MAX_RETRIES from $MIRROR_URL"
if rsync --timeout=600 \ # Pass 1: sync packages, skip db/files indices so they are never updated
-rltH --no-perms --chmod=D755,F664 --safe-links --delete-delay --delay-updates \ # before their referenced package files arrive (avoids 404s).
-v --info=progress2 \ # Pass 2: sync everything including indices now that packages are present.
"$MIRROR_URL/" "$TARGET_DIR/"; then 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" log "Sync completed successfully"
exit 0 exit 0
fi fi