Merge "Creating a function that calls /usr/bin/timeout"

This commit is contained in:
Zuul 2017-12-07 16:43:56 +00:00 committed by Gerrit Code Review
commit ff43f5a169
2 changed files with 21 additions and 6 deletions

View File

@ -31,3 +31,21 @@ function is_featureset_mixed_upgrade {
[ $(shyaml get-value mixed_upgrade "False"< $FEATURESET_FILE) = "True" ]
}
function run_with_timeout {
# First parameter is the START_JOB_TIME
# Second is the command to be executed
JOB_TIME=$1
shift
COMMAND=$@
# Leave 10 minutes for quickstart logs collection
RESERVED_LOG_TIME=10
# Use $REMAINING_TIME of infra to calculate maximum time for remaining part of job
REMAINING_TIME=${REMAINING_TIME:-180}
TIME_FOR_COMMAND=$(( REMAINING_TIME - ($(date +%s) - JOB_TIME)/60 - $RESERVED_LOG_TIME))
if [[ $TIME_FOR_COMMAND -lt 1 ]]; then
return 143
fi
/usr/bin/timeout --preserve-status ${TIME_FOR_COMMAND}m ${COMMAND}
}

View File

@ -7,6 +7,7 @@ LOCAL_WORKING_DIR="$WORKSPACE/.quickstart"
WORKING_DIR="$HOME"
LOGS_DIR=$WORKSPACE/logs
source $TRIPLEO_ROOT/tripleo-ci/scripts/oooq_common_functions.sh
## Signal to toci_gate_test.sh we've started by
touch /tmp/toci.started
@ -63,13 +64,9 @@ cp $TRIPLEO_ROOT/tripleo-ci/toci-quickstart/playbooks/* $TRIPLEO_ROOT/tripleo-qu
pushd $TRIPLEO_ROOT/tripleo-quickstart/
$QUICKSTART_PREPARE_CMD
# Use $REMAINING_TIME of infra to calculate maximum time for remaning part of job
# Leave 15 minutes for quickstart logs collection
REMAINING_TIME=${REMAINING_TIME:-180}
TIME_FOR_DEPLOY=$(( REMAINING_TIME - ($(date +%s) - START_JOB_TIME)/60 - 10 ))
/usr/bin/timeout --preserve-status ${TIME_FOR_DEPLOY}m $QUICKSTART_INSTALL_CMD \
run_with_timeout $START_JOB_TIME $QUICKSTART_INSTALL_CMD \
2>&1 | tee $LOGS_DIR/quickstart_install.log && exit_value=0 || exit_value=$?
# Print status of playbook run
[[ "$exit_value" == 0 ]] && echo "Playbook run passed successfully" || echo "Playbook run failed"
## LOGS COLLECTION