From bb195ed2c48bf2a8feb320e0d5910d598ac8cd09 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Sun, 23 Feb 2014 17:56:47 -0500 Subject: [PATCH] calculate remaining timeout locally instead of making assumptions on how much time to set aside for the timeout, instead calculate the timeout for the main gate_hook to be DEVSTACK_GATE_TIMEOUT - time elapsed when we enter the hook - 5 minutes (to handle cleanup and upload time). This will hopefully make accidental overage of the timeouts less frequent occurrence. Change-Id: I364f9c9926488699dc77dd49189d529607858316 --- devstack-vm-gate-wrap.sh | 5 ++++- functions.sh | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/devstack-vm-gate-wrap.sh b/devstack-vm-gate-wrap.sh index 110e3ae1..4c7855c2 100755 --- a/devstack-vm-gate-wrap.sh +++ b/devstack-vm-gate-wrap.sh @@ -24,6 +24,8 @@ source $WORKSPACE/devstack-gate/functions.sh +start_timer + PROJECTS="openstack-dev/devstack $PROJECTS" PROJECTS="openstack-dev/grenade $PROJECTS" PROJECTS="openstack-dev/pbr $PROJECTS" @@ -242,7 +244,8 @@ export OVERRIDE_ZUUL_BRANCH=${OVERRIDE_ZUUL_BRANCH:-$ZUUL_BRANCH} if ! function_exists "gate_hook"; then # the command we use to run the gate function gate_hook { - timeout -s 9 ${DEVSTACK_GATE_TIMEOUT}m $BASE/new/devstack-gate/devstack-vm-gate.sh + remaining_time + timeout -s 9 ${REMAINING_TIME}m $BASE/new/devstack-gate/devstack-vm-gate.sh } fi diff --git a/functions.sh b/functions.sh index 692e8c3e..7425ec2e 100644 --- a/functions.sh +++ b/functions.sh @@ -33,6 +33,18 @@ function tsfilter { }' } +# create the start timer for when the job began +function start_timer { + START_TIME=`date +%s` +} + +function remaining_time { + local now=`date +%s` + local elapsed=$(((now - START_TIME) / 60)) + REMAINING_TIME=$((DEVSTACK_GATE_TIMEOUT - elapsed - 5)) + echo "Job timeout set to: $REMAINING_TIME minutes" +} + # indent the output of a command 4 spaces, useful for distinguishing # the output of a command from the command itself function indent {