Files
threshold/enos/templates/get-token.sh
T
Josh Brand 8c0efb9715 Enos: add additional guards before authentication (#2382)
* Enos: add additional guards before authentication

Previously, we would see failures when the ALB in front of a
cluster was alive and passing healthchecks, but the database behind
had not been initialized yet.  This adds a check with an unauth'd
call to `auth-methods list` to validate the DB is up before auth.
2022-08-23 14:46:24 -04:00

29 lines
609 B
Bash

#!/bin/bash
set -e
function retry {
local retries=$1
shift
local count=0
until "$@"; do
exit=$?
wait=$((2 ** count))
count=$((count + 1))
if [ "$count" -lt "$retries" ]; then
sleep "$wait"
else
return "$exit"
fi
done
return 0
}
# make sure boundary is connected to DB (unauthenticated endpoint)
retry 10 ${BOUNDARY_PATH}/boundary auth-methods list > /dev/null
export BP="${PASSWORD}"
${BOUNDARY_PATH}/boundary authenticate password -auth-method-id=${METHOD_ID} -login-name=${LOGIN_NAME} -password=env://BP -token-name=none -format=json -keyring-type=none