6ee7a5a116
This converts the reprepro mirror script to use the common functions for timestamps and vos release. This function ssh's to the AFS server and runs vos release directly there, avoiding many issues with kerberos timeouts. This has been working successfully for the rsync mirrors. This will also send stats back so we can keep an eye on the timing. Change-Id: I1be29f2d9ecaad03b22c87819e5ae8d16c4f177e
53 lines
1.3 KiB
Bash
53 lines
1.3 KiB
Bash
#
|
|
# Common definitions and functions for mirror-update scripts
|
|
#
|
|
|
|
AFS_SERVER=afs01.dfw.openstack.org
|
|
VOS_RELEASE="ssh -i /root/.ssh/id_vos_release vos_release@${AFS_SERVER} vos release "
|
|
|
|
function echo_ts {
|
|
printf "%(%Y-%m-%d %H:%M:%S)T | %s\n" -1 "$@"
|
|
}
|
|
|
|
# Send a timer stat to statsd
|
|
# send_timer metric [start_time]
|
|
# * uses timer metric afs.release.<$1> normalised for stats
|
|
# * time will be taken from last call of start_timer, or $2 if set
|
|
function send_timer {
|
|
# Only send stats under cron conditions
|
|
if [[ ${UNDER_CRON} != 1 ]]; then
|
|
return
|
|
fi
|
|
|
|
local current
|
|
current=$(date '+%s')
|
|
local name
|
|
# "." is a separator, replace with _
|
|
name=${1//./_}
|
|
local start
|
|
start=${2-$_START_TIME}
|
|
local elapsed_ms
|
|
elapsed_ms=$(( (current - start) * 1000 ))
|
|
|
|
# See also the release-volumes.py script which sends stats to the
|
|
# same place for doc, etc. volumes.
|
|
echo "afs.release.${name}:${elapsed_ms}|ms" | nc -w 1 -u graphite.opendev.org 8125
|
|
echo "End timer for $name"
|
|
}
|
|
|
|
# See send_timer
|
|
function start_timer {
|
|
_START_TIME=$(date '+%s')
|
|
}
|
|
|
|
# Run vos release via ssh on the AFS server, and report the timing
|
|
# back to graphite
|
|
function vos_release {
|
|
local name
|
|
name=$1
|
|
|
|
start_timer
|
|
$VOS_RELEASE ${name}
|
|
send_timer ${name}
|
|
}
|