mirrorlist: make mirrorlist restart script look at .proto

In a previous commit I changed the non-templated version of
restart-mirrorlist-containers to look at the new protobuf based
mirrorlist cache file instead at the pkl file. It seems that nothing
uses the non-templated version of the script. This removes the unused
script and adapts the templated restart mirrorlist container script to
look at the protbuf based mirrorlist cache file.

Signed-off-by: Adrian Reber <adrian@lisas.de>
This commit is contained in:
Adrian Reber 2019-11-11 16:55:17 +01:00 committed by Pierre-Yves Chibon
parent e802c6f39b
commit 49d3ab1513
3 changed files with 18 additions and 105 deletions

View file

@ -1,87 +0,0 @@
#!/bin/bash
#
# This job handles hourly restarting mirrorlist container(s) and making sure all is well.
#
##
## Docker ports for mirrors
mirrorlist1="http://localhost:18081/metalink?repo=rawhide&arch=x86_64"
mirrorlist2="http://localhost:18082/metalink?repo=rawhide&arch=x86_64"
TIME_DRAIN=30
TIME_RESTART=5
TIME_DISABLE=5
##
# Initial expected state is mirrorlist1 running, mirrorlist2 running and new protobuf file
if [ ! -f /srv/mirrorlist/data/mirrorlist2/global_netblocks.txt ];
then
cp /srv/mirrorlist/data/mirrorlist1/* /srv/mirrorlist/data/mirrorlist2/
fi
## Check that the new protobuf file is newer than old protobuf file
if [ /srv/mirrorlist/data/mirrorlist1/mirrorlist_cache.proto -nt /srv/mirrorlist/data/mirrorlist2/mirrorlist_cache.proto ]; then
# new proto
:
else
# No new proto
exit 0
fi
## check mirrorlist1 running
if [ `systemctl show mirrorlist1 -p ActiveState` != 'ActiveState=active' ]; then
# mirrorlist1 not running, there is a problem
echo "Error: mirrorlist1 is not running as expected"
exit 1
fi
# check mirrorlist2 (old proto and see that it's processing ok)
curl -q -H mirrors.fedoraproject.org ${mirrorlist2} -s -f --retry 50 --retry-delay 10 --retry-connrefused --retry-max-time 180 | grep "sha512" >/dev/null
if [ $? != 0 ]; then
echo "ERROR: mirrorlist2 not processing correctly"
exit 1
fi
# Drain mirrorlist1. This is safe since we assured that local2 is serving
echo "enable server mirror-lists-backend/mirrorlist-local2" | nc -U /var/run/haproxy-admin >& /dev/null
echo "set server mirror-lists-backend/mirrorlist-local1 state drain" | nc -U /var/run/haproxy-admin >& /dev/null
sleep ${TIME_DRAIN}
echo "disable server mirror-lists-backend/mirrorlist-local1" | nc -U /var/run/haproxy-admin >& /dev/null
sleep ${TIME_DISABLE}
# restart mirrorlist1 (new proto and make sure it's processing ok)
systemctl restart mirrorlist1
sleep ${TIME_RESTART}
curl -q -H mirrors.fedoraproject.org ${mirrorlist1} -s -f --retry 50 --retry-delay 10 --retry-connrefused --retry-max-time 180 | grep "sha512" >/dev/null
if [ $? != 0 ]; then
echo "ERROR: mirrorlist1 did not restart correctly"
exit 1
fi
# New mirrorlist seems to be working, put it back into service
echo "enable server mirror-lists-backend/mirrorlist-local1" | nc -U /var/run/haproxy-admin >& /dev/null
sleep ${TIME_RESTART}
# copy new proto to mirrorlist2
cp -a /srv/mirrorlist/data/mirrorlist1/* /srv/mirrorlist/data/mirrorlist2/
# Drain mirrorlist2
echo "set server mirror-lists-backend/mirrorlist-local2 state drain" | nc -U /var/run/haproxy-admin >& /dev/null
sleep ${TIME_DRAIN}
echo "disable server mirror-lists-backend/mirrorlist-local2" | nc -U /var/run/haproxy-admin >& /dev/null
sleep ${TIME_DISABLE}
# restart mirrorlist2
systemctl restart mirrorlist2
sleep ${TIME_RESTART}
curl -q -H mirrors.fedoraproject.org ${mirrorlist2} -o/dev/null -s -f --retry 50 --retry-delay 10 --retry-connrefused --retry-max-time 180
if [ $? != 0 ]; then
echo "ERROR: mirrorlist2 did not restart correctly"
exit 1
fi
echo "enable server mirror-lists-backend/mirrorlist-local2" | nc -U /var/run/haproxy-admin >& /dev/null

View file

@ -51,7 +51,7 @@
tags:
- mirrorlist_proxy
- name: make sure mirrormanager user can write new pkl files
- name: make sure mirrormanager user can write new protobuf based cache file
file: dest="{{item}}" owner=mirrormanager group=mirrormanager
with_items:
- /srv/mirrorlist/data
@ -125,7 +125,7 @@
check_mode: yes
# We deploy two service files. Both listen on a different port, so that we can switch
# them out as part of the pkl deployment without having any local downtime.
# them out as part of the protobuf cache deployment without having any local downtime.
- name: Deploy service files
template: src=mirrorlist.service.j2 dest=/etc/systemd/system/mirrorlist{{ item }}.service
with_items:
@ -137,7 +137,7 @@
- reload systemd
# We deploy two service files. Both listen on a different port, so that we can switch
# them out as part of the pkl deployment without having any local downtime.
# them out as part of the protobuf cache deployment without having any local downtime.
- name: Deploy service files for m3
template: src=mirrorlist.service.j2 dest=/etc/systemd/system/mirrorlist{{ item }}.service
with_items:
@ -165,13 +165,13 @@
- mirrorlist_proxy
when: datacenter == 'phx2'
# install our cron script to handle hourly new pkl changes.
- name: install script to restart mirrorlist containers on pkl changes
# install our cron script to handle hourly new protbuf cache changes.
- name: install script to restart mirrorlist containers on protobuf cache changes
template: src=restart-mirrorlist-containers.j2 dest=/usr/local/bin/restart-mirrorlist-containers mode=0755
tags:
- mirrorlist_proxy
- name: Setup hourly cron at for pkl reload restarts
- name: Setup hourly cron at for mirrorlist restarts
cron: name="restart-mirrorlist-containers" minute="20" user="root"
job="/usr/local/bin/restart-mirrorlist-containers"
cron_file=restart-mirrorlist-containers
@ -200,13 +200,13 @@
- mirrorlist_proxy
- name: check for mirrorlist files
stat: path=/srv/mirrorlist/data/mirrorlist1/mirrorlist_cache.pkl
stat: path=/srv/mirrorlist/data/mirrorlist1/mirrorlist_cache.proto
register: mirrorlist_cache_status
tags:
- mirrorlist_proxy
- name: Deploy mirrorlist data files (if this is a initial install)
command: "rsync -az --delete-delay --delay-updates --delete /var/lib/mirrormanager/mirrorlist_cache.pkl /var/lib/mirrormanager/global_netblocks.txt /var/lib/mirrormanager/i2_netblocks.txt {{ inventory_hostname }}:/srv/mirrorlist/data/mirrorlist1/"
command: "rsync -az --delete-delay --delay-updates --delete /var/lib/mirrormanager/mirrorlist_cache.proto /usr/share/mirrormanager2/country_continent.csv /var/lib/mirrormanager/global_netblocks.txt /var/lib/mirrormanager/i2_netblocks.txt {{ inventory_hostname }}:/srv/mirrorlist/data/mirrorlist1/"
become: yes
become_user: mirrormanager
delegate_to: "mm-backend01.phx2.fedoraproject.org"

View file

@ -18,7 +18,7 @@ TIME_DISABLE=5
##
# Initial expected state is mirrorlist1 running, mirrorlist2 running and new pkl
# Initial expected state is mirrorlist1 running, mirrorlist2 running and new protbuf cache
if [ ! -f /srv/mirrorlist/data/mirrorlist2/global_netblocks.txt ];
then
@ -34,12 +34,12 @@ fi
{% endif %}
## Check that pkl is newer than old pkl
if [ /srv/mirrorlist/data/mirrorlist1/mirrorlist_cache.pkl -nt /srv/mirrorlist/data/mirrorlist2/mirrorlist_cache.pkl ]; then
# new pkl
## Check that protbuf cache is newer than old protobuf cache
if [ /srv/mirrorlist/data/mirrorlist1/mirrorlist_cache.proto -nt /srv/mirrorlist/data/mirrorlist2/mirrorlist_cache.proto ]; then
# new proto
:
else
# No new pkl
# No new proto
exit 0
fi
## check mirrorlist1 running
@ -49,7 +49,7 @@ if [ `systemctl show mirrorlist1 -p ActiveState` != 'ActiveState=active' ]; then
exit 1
fi
# check mirrorlist2 (old pkl and see that it's processing ok)
# check mirrorlist2 (old protbuf cache and see that it's processing ok)
curl -q -H mirrors.fedoraproject.org ${mirrorlist2} -s -f --retry 50 --retry-delay 10 --retry-connrefused --retry-max-time 180 | grep "sha512" >/dev/null
if [ $? != 0 ]; then
echo "ERROR: mirrorlist2 not processing correctly"
@ -57,7 +57,7 @@ if [ $? != 0 ]; then
fi
{% if datacenter == 'phx2' %}
# check mirrorlist3 (old pkl and see that it's processing ok)
# check mirrorlist3 (old protbuf cache and see that it's processing ok)
curl -q -H mirrors.fedoraproject.org ${mirrorlist3} -s -f --retry 50 --retry-delay 10 --retry-connrefused --retry-max-time 180 | grep "sha512" >/dev/null
if [ $? != 0 ]; then
echo "ERROR: mirrorlist3 not processing correctly"
@ -73,7 +73,7 @@ sleep ${TIME_DRAIN}
echo "disable server mirror-lists-backend/mirrorlist-local1" | nc -U /var/run/haproxy-admin >& /dev/null
sleep ${TIME_DISABLE}
# restart mirrorlist1 (new pkl and make sure it's processing ok)
# restart mirrorlist1 (new protbuf cache and make sure it's processing ok)
systemctl stop mirrorlist1
sleep 1
systemctl start mirrorlist1
@ -94,7 +94,7 @@ fi
echo "enable server mirror-lists-backend/mirrorlist-local1" | nc -U /var/run/haproxy-admin >& /dev/null
sleep ${TIME_RESTART}
# copy new pkl to mirrorlist2
# copy new protbuf cache to mirrorlist2
cp -a /srv/mirrorlist/data/mirrorlist1/* /srv/mirrorlist/data/mirrorlist2/
# Drain mirrorlist2
@ -122,7 +122,7 @@ fi
echo "enable server mirror-lists-backend/mirrorlist-local2" | nc -U /var/run/haproxy-admin >& /dev/null
{% if datacenter == 'phx2' %}
# copy new pkl to mirrorlist3
# copy new protbuf cache to mirrorlist3
cp -a /srv/mirrorlist/data/mirrorlist1/* /srv/mirrorlist/data/mirrorlist3/
# Drain mirrorlist3