diff --git a/devstack-vm-gate-wrap.sh b/devstack-vm-gate-wrap.sh index 214865d9..bc9a6b94 100755 --- a/devstack-vm-gate-wrap.sh +++ b/devstack-vm-gate-wrap.sh @@ -401,9 +401,9 @@ fi if ! function_exists "gate_hook"; then # the command we use to run the gate function gate_hook { - remaining_time - timeout -s 9 ${REMAINING_TIME}m $BASE/new/devstack-gate/devstack-vm-gate.sh + $BASE/new/devstack-gate/devstack-vm-gate.sh } + export -f gate_hook fi echo "Triggered by: https://review.openstack.org/$ZUUL_CHANGE patchset $ZUUL_PATCHSET" @@ -519,11 +519,11 @@ fi # Note that hooks should be multihost aware if necessary. # devstack-vm-gate-wrap.sh will not automagically run the hooks on each node. # Run pre test hook if we have one -call_hook_if_defined "pre_test_hook" +timeout_hook call_hook_if_defined "pre_test_hook" # Run the gate function echo "Running gate_hook" -gate_hook +timeout_hook "gate_hook" GATE_RETVAL=$? RETVAL=$GATE_RETVAL @@ -537,7 +537,7 @@ fi # Run post test hook if we have one if [ $GATE_RETVAL -eq 0 ]; then # Run post_test_hook if we have one - call_hook_if_defined "post_test_hook" + timeout_hook call_hook_if_defined "post_test_hook" RETVAL=$? fi diff --git a/functions.sh b/functions.sh index 7f57b584..e74b48ca 100644 --- a/functions.sh +++ b/functions.sh @@ -987,3 +987,12 @@ function ovs_gre_bridge { fi done } + +# Timeout hook calls implemented as bash functions. Note this +# forks and execs a new bash in order to use the timeout utility +# which cannot operate on bash functions directly. +function timeout_hook { + local cmd=$@ + remaining_time + timeout -s 9 ${REMAINING_TIME}m bash -c "source $WORKSPACE/devstack-gate/functions.sh && $cmd" +}