From ff3b0aa9e0c19a034f005cde6c4d9b1d225a54ad Mon Sep 17 00:00:00 2001 From: "Neely, Travis (tn720x)" Date: Thu, 28 Jan 2021 12:10:10 -0600 Subject: [PATCH] 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 --- helm-toolkit/Chart.yaml | 2 +- .../templates/scripts/_ks-service.sh.tpl | 35 +++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/helm-toolkit/Chart.yaml b/helm-toolkit/Chart.yaml index 8684c77db9..46962abcdd 100644 --- a/helm-toolkit/Chart.yaml +++ b/helm-toolkit/Chart.yaml @@ -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: diff --git a/helm-toolkit/templates/scripts/_ks-service.sh.tpl b/helm-toolkit/templates/scripts/_ks-service.sh.tpl index 875d6c5789..eb9b9314d8 100644 --- a/helm-toolkit/templates/scripts/_ks-service.sh.tpl +++ b/helm-toolkit/templates/scripts/_ks-service.sh.tpl @@ -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 | \ - 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 \ - --name="${OS_SERVICE_NAME}" \ - --description "${OS_SERVICE_DESC}" \ - --enable \ - "${OS_SERVICE_TYPE}") -fi +# 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 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}") {{- end }}