Fix retries

Change-Id: Id1da47d878b3db46872721a5f9aa384a6fe675c9
This commit is contained in:
Mohammed Naser 2020-08-08 16:53:02 -04:00
parent dfe5f77ee5
commit 67e6c49f60
3 changed files with 23 additions and 22 deletions

View File

@ -17,8 +17,6 @@
This module contains a few common functions for identity management
"""
import kopf
from openstack_operator import utils
@ -32,22 +30,19 @@ def ensure_service(name, service_type, desc, url=None, path=""):
path: sub path of endpoint
"""
try:
# Create or resume service
utils.create_or_update('identity/service.yml.j2', name=name,
type=service_type, description=desc)
# Create or resume service
utils.create_or_update('identity/service.yml.j2', name=name,
type=service_type, description=desc)
# Create or resume endpoints
internal_url = public_url = \
"http://" + name + ".openstack.svc.cluster.local" + path
# Create or resume endpoints
internal_url = public_url = \
"http://" + name + ".openstack.svc.cluster.local" + path
if url is not None:
public_url = "https://" + url + path
utils.create_or_update('identity/endpoint.yml.j2',
service=service_type, interface='internal',
url=internal_url)
utils.create_or_update('identity/endpoint.yml.j2',
service=service_type, interface='public',
url=public_url)
except Exception as ex:
raise kopf.TemporaryError(str(ex), delay=5)
if url is not None:
public_url = "https://" + url + path
utils.create_or_update('identity/endpoint.yml.j2',
service=service_type, interface='internal',
url=internal_url)
utils.create_or_update('identity/endpoint.yml.j2',
service=service_type, interface='public',
url=public_url)

View File

@ -25,7 +25,10 @@ from openstack_operator import utils
def _get_service_by_type(conn, service_type):
"""Get a service from Keystone based on service type."""
services = conn.search_services(filters={"type": service_type})
try:
services = conn.search_services(filters={"type": service_type})
except Exception as ex:
raise kopf.TemporaryError(str(ex), delay=5)
if len(services) > 1:
raise RuntimeError("Multiple services with type: %s" % service_type)

View File

@ -30,8 +30,11 @@ def _get_service(conn, name, service_type):
found more than one or return None if it couldn't find it
"""
services = conn.search_services(name_or_id=name,
filters={"type": service_type})
try:
services = conn.search_services(name_or_id=name,
filters={"type": service_type})
except ConnectionRefusedError:
raise kopf.TemporaryError("Keystone is not up yet", delay=5)
if len(services) > 1:
raise RuntimeError("Found multiple services with name and type")