From d922c4e0a421cab25dd2d5a99837c9f6029e2d94 Mon Sep 17 00:00:00 2001 From: Simon Paillard Date: Fri, 20 Sep 2013 22:40:00 +0200 Subject: Handling of trigger errors: fix logging and email reports - No separate log file for errors - One mail per faulty pushed mirror --- bin/runmirrors | 6 +++++- etc/common | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/bin/runmirrors b/bin/runmirrors index 93922b6..a84c27b 100755 --- a/bin/runmirrors +++ b/bin/runmirrors @@ -117,6 +117,10 @@ PUSHARCHIVE=${PUSHARCHIVE:-"${CONF}"} PUSHDELAY=${PUSHDELAY:-600} # Which ssh key to use? KEYFILE=${KEYFILE:-".ssh/pushmirror"} + +# start a new log +savelog "${LOG}" > /dev/null + # where to send mails to if [ "x$(hostname -d)x" != "xdebian.orgx" ]; then # We are not on a debian.org host @@ -146,7 +150,7 @@ umask 022 mkdir -p "${LOGDIR}" mkdir -p "${LOCKDIR}" -trap 'log "Mirrorpush done" >> "${LOG}"; savelog "${LOG}" > /dev/null' EXIT +trap 'log "Mirrorpush done" >> "${LOG}"' EXIT log "Pushing leaf mirrors. Inside ftpsync: ${FROMFTPSYNC}. Pushkind: ${PUSHKIND}" >> "${LOG}" diff --git a/etc/common b/etc/common index ef5b4b6..bd35387 100644 --- a/etc/common +++ b/etc/common @@ -95,7 +95,12 @@ signal () { # Default normal "fire and forget" push. We background that, we do not care about the mirrors doings log "Sending normal push" >> "${LOGDIR}/${MIRROR}.log" PUSHARGS1="sync:all" - ssh -f $SSH_OPTIONS "${HOSTNAME}" "${PUSHARGS} ${PUSHARGS1}" >>"${LOGDIR}/${MIRROR}.log" + ssh -n $SSH_OPTIONS "${HOSTNAME}" "${PUSHARGS} ${PUSHARGS1}" >>"${LOGDIR}/${MIRROR}.log" 2>&1 + if [ $? -eq 255 ]; then + error "Trigger to ${HOSTNAME} failed" >> "${LOG}" + else + log "Trigger to ${HOSTNAME} succeed" >> "${LOG}" + fi elif [ "xstagedx" = "x${PUSHTYPE}x" ] || [ "xmhopx" = "x${PUSHTYPE}x" ]; then # Want a staged push. Fine, lets do that. Not backgrounded. We care about the mirrors doings. log "Sending staged push" >> "${LOGDIR}/${MIRROR}.log" @@ -105,6 +110,11 @@ signal () { # Step1: Do a push to only sync stage1, do not background PUSHARGS1="sync:stage1" ssh $SSH_OPTIONS "${HOSTNAME}" "${PUSHARGS} ${PUSHARGS1}" >>"${LOGDIR}/${MIRROR}.log" 2>&1 + if [ $? -eq 255 ]; then + error "Trigger to ${HOSTNAME} failed" >> "${LOG}" + else + log "Trigger to ${HOSTNAME} succeed" >> "${LOG}" + fi touch "${PUSHLOCKOWN}" # Step2: Wait for all the other "lock"files to appear. @@ -153,6 +163,11 @@ signal () { PUSHARGS2="sync:stage2" log "Now doing the second stage push" >> "${LOGDIR}/${MIRROR}.log" ssh $SSH_OPTIONS "${HOSTNAME}" "${PUSHARGS} ${PUSHARGS2}" >>"${LOGDIR}/${MIRROR}.log" 2>&1 + if [ $? -eq 255 ]; then + error "Trigger to ${HOSTNAME} failed" >> "${LOG}" + else + log "Trigger to ${HOSTNAME} succeed" >> "${LOG}" + fi fi else # Can't decide? Then you get nothing. -- cgit v1.2.3