Add a 600s timeout when creating enable-ssh-admin workflow

If enable-ssh-admin.sh workflow fails, the script was looping forever,
because it only checks if the workflow is SUCCESSFUL.

Now, we have a timeout of 500 seconds and when it reaches it, it'll stop
and print a debug message.

Note: we're using ENABLE_SSH_ADMIN_TIMEOUT variable which can be
overriden when calling the script; the default value was taken from
tripleoclient/constants.

Change-Id: Ie183321bc23164745237d7036885f6e6dcfef859
Closes-Bug: #1876646
This commit is contained in:
Emilien Macchi 2020-05-03 22:40:12 -04:00
parent 1cdb8c8f99
commit b3127ac3f1
1 changed files with 24 additions and 6 deletions

View File

@ -13,6 +13,8 @@ SSH_TIMEOUT_OPTIONS=${SSH_TIMEOUT_OPTIONS:-"-o ConnectionAttempts=6 -o ConnectTi
SSH_HOSTKEY_OPTIONS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
SHORT_TERM_KEY_COMMENT="TripleO split stack short term key"
SLEEP_TIME=5
# The default is defined in tripleoclient/constants.py
ENABLE_SSH_ADMIN_TIMEOUT=${ENABLE_SSH_ADMIN_TIMEOUT:-"600"}
# needed to handle where python lives
function get_python() {
@ -34,8 +36,24 @@ function overcloud_ssh_key_json {
function workflow_finished {
local execution_id="$1"
openstack workflow execution show -f shell $execution_id | grep 'state="SUCCESS"' > /dev/null
}
counter=$(( $ENABLE_SSH_ADMIN_TIMEOUT / $SLEEP_TIME ))
while [ $counter -gt 0 ]
do
RESULT=$(openstack workflow execution show -f value -c state $execution_id)
if [ "$RESULT" == "ERROR" ]; then
echo "Workflow $execution_id finished with error. Check mistral logs."
return 1
elif [ "$RESULT" == "SUCCESS" ]; then
echo "Workflow $execution_id finished with success."
return 0
else
sleep $SLEEP_TIME
fi
counter=$(( $counter - 1 ))
done
echo "Workflow $execution_id did not finish after $ENABLE_SSH_ADMIN_TIMEOUT seconds."
return 1
function generate_short_term_keys {
local tmpdir=$(mktemp -d)
@ -78,10 +96,10 @@ if [ -z "$EXECUTION_ID" ]; then
fi
echo -n "Waiting for the workflow execution to finish (id $EXECUTION_ID)."
while ! workflow_finished $EXECUTION_ID; do
sleep $SLEEP_TIME
echo -n .
done
if ! workflow_finished $EXECUTION_ID; then
exit 1
fi
echo # newline after the previous dots
for HOST in $OVERCLOUD_HOSTS; do