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

This commit is contained in:
Zuul 2020-05-07 15:35:20 +00:00 committed by Gerrit Code Review
commit 9c55673103

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