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 {