system-config/playbooks/roles/mirror-update/files/fedora-mirror-update
Clark Boylan 0901c4509b Cleanup the Fedora 36 mirror content
This is mostly a formality as upstream of us the content was already
removed and we synced that removal. But this will do a little extra
cleanup for us to make it look even less like a mirror of Fedora 36.

I also kept the structure of the file rather than deleting the code to
sync Fedora content. This should make it easy for someone to pick this
back up in the future if there is a need and ability to maintain it.

Change-Id: I976304727a06bd36eb05201043aac3861ee66937
2023-11-21 09:10:52 -08:00

156 lines
5.3 KiB
Bash
Executable File

#!/bin/bash -e
# Copyright 2016 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
source /usr/share/mirror-update/functions.sh
MIRROR_VOLUME=$1
# Runs with timeout under cron
if [[ ${UNDER_CRON:-0} -eq 0 ]]; then
echo_ts "Running interactively"
TIMEOUT=""
set -x
else
TIMEOUT="timeout -k 2m 90m"
fi
BASE="/afs/.openstack.org/mirror/fedora"
# NOTE(ianw): 2018-11 we dropped "-p" from the rsync commands
# because upstream starting putting setgid bits on directories,
# which you have to have admin permissions in AFS to set.
# https://pagure.io/releng/issue/7921
MIRROR="rsync://mirror.facebook.net/fedora/linux"
K5START="k5start -t -f /etc/fedora.keytab service/fedora-mirror -- ${TIMEOUT}"
echo_ts "----- START FEDORA MIRROR RSYNC RUN -----"
# Purge old releases
echo_ts "Purging old mirrors"
$K5START rm -rf $BASE/releases/35 $BASE/updates/35 $BASE/releases/36 $BASE/updates/36 $BASE/releases/37 $BASE/updates/37 $BASE/development/rawhide
# We set RELEASE_REPOS and UPDATE_REPOS to empty strings to fail
# the conditions below skipping any rsyncing. We don't just simply
# exit 0 here because we do need the vos release at the end to run
# and publish the cleanups done by the rm above.
#
# The code below isn't simply removed to make it easy for people to
# resurrect this in the future should conditions change making
# fedora test nodes a more viable option again.
# A list of release repos to sync eg 'releases/36 releases/37'
RELEASE_REPOS=''
if [ -n "$RELEASE_REPOS" ]; then
for REPO in "$RELEASE_REPOS"; do
if ! [ -f $BASE/$REPO ]; then
$K5START mkdir -p $BASE/$REPO
fi
echo_ts "Running rsync for $REPO..."
$K5START rsync -rltvz \
--delete \
--delete-excluded \
--exclude="iso/" \
--exclude="images/" \
--exclude="isolinux/" \
--exclude="Cloud/x86_64/images/*.box" \
--exclude="Container" \
--exclude="Kinoite" \
--exclude="Server" \
--exclude="Silverblue" \
--exclude="Spins" \
--exclude="Workstation" \
--exclude="aarch64/" \
--exclude="armhfp/" \
--exclude="source/" \
--exclude="x86_64/debug/" \
--exclude="x86_64/drpms/" \
--exclude="snapshot/" \
--exclude=".~tmp~/" \
--exclude=".private/" \
--exclude=".nfs*" \
$MIRROR/$REPO/ $BASE/$REPO/
echo_ts "... done"
done
fi
# A list of update repos to sync eg 'updates/36 updates/37'
UPDATE_REPOS=''
if [ -n "$UPDATE_REPOS" ]; then
for REPO in "$UPDATE_REPOS"; do
if ! [ -f $BASE/$REPO ]; then
$K5START mkdir -p $BASE/$REPO
fi
echo_ts "Running rsync for $REPO..."
$K5START rsync -rltvz \
--delete \
--delete-excluded \
--exclude="aarch64/" \
--exclude="armhfp/" \
--exclude="i386/" \
--exclude="source/" \
--exclude="SRPMS/" \
--exclude="x86_64/debug" \
--exclude="x86_64/drpms" \
--exclude="snapshot/" \
--exclude=".~tmp~/" \
--exclude=".private/" \
--exclude=".nfs*" \
$MIRROR/$REPO/ $BASE/$REPO/
echo_ts "... done"
done
fi
# TODO(pabelanger): Validate rsync process
date --iso-8601=ns | $K5START tee $BASE/timestamp.txt
# Now sleep for 20 minutes. openafs "pads" its incremental
# replication on "vos release" by -15 minutes to account for clock
# skew between hosts.
#
# We can get into a negative feedback loop with this, particularly if
# we have a series of big updates, or run things by hand to avoid
# timeouts.
#
# Consider the case of a large mirror pulse (perhaps a new distro
# release is included, etc.). The "Last Update" time on the volume
# will indicate when this run finished.
#
# The last 15 minutes of that run could have brought in a significant
# amount of data. Now we move onto the next mirror pulse, and the
# "vos release" below will try to sync the remote R/O volume from
# "Last Update - 15 minutes" to now(). If you include the data from
# this pulse, we are now dragging across potentially *a lot* of data;
# enough to make the whole thing timeout. Then the volume is locked,
# and we keep putting more data ontop with each cron run making it
# even worse.
#
# By sleeping here for 15+ minutes and doing a trivial write, we can
# ensure that when the *next* release says "sync from Last Update - 15
# minutes" it will *only* include this trivial write, and not
# potentially this entire mirror pulse data too.
sleep $(( 20 * 60 ))
date --iso-8601=ns | $K5START tee $BASE/timestamp.txt
echo_ts "Running vos release."
vos_release $MIRROR_VOLUME | \
while IFS= read -r line; do echo_ts "$line"; done
echo_ts "... done"
echo_ts "----- END FEDORA MIRROR RSYNC RUN -----"
printf "\n\n"