Fix retries
Change-Id: Id1da47d878b3db46872721a5f9aa384a6fe675c9
This commit is contained in:
parent
dfe5f77ee5
commit
67e6c49f60
@ -17,8 +17,6 @@
|
|||||||
This module contains a few common functions for identity management
|
This module contains a few common functions for identity management
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import kopf
|
|
||||||
|
|
||||||
from openstack_operator import utils
|
from openstack_operator import utils
|
||||||
|
|
||||||
|
|
||||||
@ -32,22 +30,19 @@ def ensure_service(name, service_type, desc, url=None, path=""):
|
|||||||
path: sub path of endpoint
|
path: sub path of endpoint
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
# Create or resume service
|
||||||
# Create or resume service
|
utils.create_or_update('identity/service.yml.j2', name=name,
|
||||||
utils.create_or_update('identity/service.yml.j2', name=name,
|
type=service_type, description=desc)
|
||||||
type=service_type, description=desc)
|
|
||||||
|
|
||||||
# Create or resume endpoints
|
# Create or resume endpoints
|
||||||
internal_url = public_url = \
|
internal_url = public_url = \
|
||||||
"http://" + name + ".openstack.svc.cluster.local" + path
|
"http://" + name + ".openstack.svc.cluster.local" + path
|
||||||
|
|
||||||
if url is not None:
|
if url is not None:
|
||||||
public_url = "https://" + url + path
|
public_url = "https://" + url + path
|
||||||
utils.create_or_update('identity/endpoint.yml.j2',
|
utils.create_or_update('identity/endpoint.yml.j2',
|
||||||
service=service_type, interface='internal',
|
service=service_type, interface='internal',
|
||||||
url=internal_url)
|
url=internal_url)
|
||||||
utils.create_or_update('identity/endpoint.yml.j2',
|
utils.create_or_update('identity/endpoint.yml.j2',
|
||||||
service=service_type, interface='public',
|
service=service_type, interface='public',
|
||||||
url=public_url)
|
url=public_url)
|
||||||
except Exception as ex:
|
|
||||||
raise kopf.TemporaryError(str(ex), delay=5)
|
|
||||||
|
@ -25,7 +25,10 @@ from openstack_operator import utils
|
|||||||
def _get_service_by_type(conn, service_type):
|
def _get_service_by_type(conn, service_type):
|
||||||
"""Get a service from Keystone based on 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:
|
if len(services) > 1:
|
||||||
raise RuntimeError("Multiple services with type: %s" % service_type)
|
raise RuntimeError("Multiple services with type: %s" % service_type)
|
||||||
|
@ -30,8 +30,11 @@ def _get_service(conn, name, service_type):
|
|||||||
found more than one or return None if it couldn't find it
|
found more than one or return None if it couldn't find it
|
||||||
"""
|
"""
|
||||||
|
|
||||||
services = conn.search_services(name_or_id=name,
|
try:
|
||||||
filters={"type": service_type})
|
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:
|
if len(services) > 1:
|
||||||
raise RuntimeError("Found multiple services with name and type")
|
raise RuntimeError("Found multiple services with name and type")
|
||||||
|
Loading…
Reference in New Issue
Block a user