From a8f451795600a523f5506494dd235105241add8e Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 4 Jun 2014 16:43:35 -0400 Subject: [PATCH] Force ntpdate before we start the timer To address the fact that some rax compute nodes seem to start with a time 4hrs in the past, then jump forward abruptly, force ntpdate update before we start accounting for time locally. Otherwise our math might be very very wrong. Change-Id: Ie5b7a6295f33a6639374c7ee72c682df5a0d26e9 --- functions.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/functions.sh b/functions.sh index d350fa6e..c3b80015 100644 --- a/functions.sh +++ b/functions.sh @@ -45,6 +45,16 @@ function tsfilter { # create the start timer for when the job began function start_timer { + # first make sure the time is right, so we don't go into crazy land + # later if the system decides to apply an ntp date and we jump forward + # 4 hrs (which has happened) + local default_ntp_server=$( + grep ^server /etc/ntp.conf | head -1 | awk '{print $2}') + local ntp_server=${NTP_SERVER:-$default_ntp_server} + sudo service ntp stop + sudo /usr/sbin/ntpdate $ntp_server + sudo service ntp start + sleep 1 START_TIME=`date +%s` } @@ -545,7 +555,7 @@ function cleanup_host { # caught up which aren't really text, don't worry about that) find $BASE/logs/sudoers.d $BASE/logs/etc -type f -exec mv '{}' '{}'.txt \; - # rabbitmq + # rabbitmq if [ -f $BASE/logs/rabbitmq/ ]; then find $BASE/logs/rabbitmq -type f -exec mv '{}' '{}'.txt \; fi