Skip to content
Snippets Groups Projects
Commit e738c76b authored by Tim Kreuzer's avatar Tim Kreuzer
Browse files

improved exception handling when collecting user specific flavors

parent 47876cbe
No related branches found
No related tags found
No related merge requests found
...@@ -60,14 +60,18 @@ async def async_get_flavors(log, user=None): ...@@ -60,14 +60,18 @@ async def async_get_flavors(log, user=None):
req = HTTPRequest( req = HTTPRequest(
url_token[0], url_token[0],
headers={"Authorization": f"Basic {url_token[1]}"}, headers={"Authorization": f"Basic {url_token[1]}"},
request_timeout=1,
) )
tasks.append(http_client.fetch(req, raise_error=False)) tasks.append(http_client.fetch(req, raise_error=False))
results = await asyncio.gather(*tasks) try:
results = await asyncio.gather(*tasks, return_exceptions=True)
names_results = list(zip(initial_system_names_list, results)) names_results = list(zip(initial_system_names_list, results))
for name_result in names_results: for name_result in names_results:
if name_result[1].code == 200: if name_result[1].code == 200:
try: try:
log.info(f"OutpostFlavors - {name_result[0]} successful") log.info(
f"OutpostFlavors - {name_result[0]} successful"
)
result_json = json.loads(name_result[1].body) result_json = json.loads(name_result[1].body)
_outpost_flavors_cache[name_result[0]] = result_json _outpost_flavors_cache[name_result[0]] = result_json
except: except:
...@@ -80,6 +84,8 @@ async def async_get_flavors(log, user=None): ...@@ -80,6 +84,8 @@ async def async_get_flavors(log, user=None):
) )
except: except:
log.exception("OutpostFlavors failed, return empty dict") log.exception("OutpostFlavors failed, return empty dict")
except:
log.exception("OutpostFlavors failed, return empty dict")
# If it's an user authenticated request, we override the available flavors, if # If it's an user authenticated request, we override the available flavors, if
# there's a dict with available flavors in auth_state. # there's a dict with available flavors in auth_state.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment