Creating a function that calls /usr/bin/timeout
Due the fact that in the future, we will have several ansible-playbooks calls, we need to create a function that will calculate the remaining time for each call. This function gets the START_JOB_TIME and calculate how much time still has, and execute the command with /usr/bin/timeout Change-Id: Ib4766ea144baaaf1b47899c4923adf40a3be4582
This commit is contained in:
parent
3cd744dfb3
commit
606304b3b5
@ -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}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user