From 4505ddd0eef306672a5463507366ded541d14f33 Mon Sep 17 00:00:00 2001 From: gluap Date: Sat, 25 Dec 2021 20:55:13 +0100 Subject: [PATCH] add retry to keycloak connection --- api/obs/api/routes/login.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/obs/api/routes/login.py b/api/obs/api/routes/login.py index f88a8b3..4a8bc1a 100644 --- a/api/obs/api/routes/login.py +++ b/api/obs/api/routes/login.py @@ -1,3 +1,4 @@ +import asyncio import logging import os @@ -25,6 +26,14 @@ logging.getLogger('oic').setLevel(logging.INFO) async def connect_auth_client(app, loop): client.allow["issuer_mismatch"] = True client.provider_config(app.config.KEYCLOAK_URL) + try: + client.provider_config(app.config.KEYCLOAK_URL) + except: + log.exception(f"could not connect to {app.config.KEYCLOAK_URL}") + log.info("will retry") + await asyncio.sleep(2) + log.info("retrying") + await connect_auth_client(app,loop) client.store_registration_info( RegistrationResponse( client_id=app.config.KEYCLOAK_CLIENT_ID,