Allow openstack service list to retry in event of keystone connection issues

We've seen a few cases where the openstack service list is unable
to establish a connection with keystone thus causing the check to fail.
When this happens, an additional service is created unnecessarily.
When the addtional service is created, it tends to cause issues since
there are no endpoints asscociated with the new service.

Allow this check to retry several times.

Change-Id: I5a1985c680e90de71549177ffc3faf848a831bfa
This commit is contained in:
Neely, Travis (tn720x) 2021-01-28 12:10:10 -06:00
parent 6090e8243d
commit ff3b0aa9e0
2 changed files with 25 additions and 12 deletions

View File

@ -15,7 +15,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Helm-Toolkit
name: helm-toolkit
version: 0.2.2
version: 0.2.3
home: https://docs.openstack.org/openstack-helm
icon: https://www.openstack.org/themes/openstack/images/project-mascots/OpenStack-Helm/OpenStack_Project_OpenStackHelm_vertical.png
sources:

View File

@ -36,16 +36,29 @@ OS_SERVICE_DESC="${OS_REGION_NAME}: ${OS_SERVICE_NAME} (${OS_SERVICE_TYPE}) serv
# Get Service ID if it exists
unset OS_SERVICE_ID
OS_SERVICE_ID=$( openstack service list -f csv --quote none | \
# If OS_SERVICE_ID is blank (due to the service not being ready yet)
# then wait a few seconds to give it additional time to be ready
# and try again
for i in {1...3}
do
OS_SERVICE_ID=$( openstack service list -f csv --quote none | \
grep ",${OS_SERVICE_NAME},${OS_SERVICE_TYPE}$" | \
sed -e "s/,${OS_SERVICE_NAME},${OS_SERVICE_TYPE}//g" )
# If a Service ID was not found, then create the service
if [[ -z ${OS_SERVICE_ID} ]]; then
OS_SERVICE_ID=$(openstack service create -f value -c id \
# If the service was found, go ahead and exit successfully.
if [[ -n "${OS_SERVICE_ID}" ]]; then
exit 0
fi
sleep 2
done
# If we've reached this point and a Service ID was not found,
# then create the service
OS_SERVICE_ID=$(openstack service create -f value -c id \
--name="${OS_SERVICE_NAME}" \
--description "${OS_SERVICE_DESC}" \
--enable \
"${OS_SERVICE_TYPE}")
fi
{{- end }}