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
This commit is contained in:
Sean Dague
2014-02-23 17:56:47 -05:00
parent 18a76ac6a4
commit bb195ed2c4
2 changed files with 16 additions and 1 deletions

View File

@@ -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

View File

@@ -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 {