outposts: fix error when getting state for non-existent outpost

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-12-20 19:44:08 +01:00
parent 68637cf7cf
commit 80d0b14bb8
2 changed files with 3 additions and 0 deletions

View file

@ -109,6 +109,7 @@ def before_send(event: dict, hint: dict) -> Optional[dict]:
"django_redis",
"django.security.DisallowedHost",
"django_redis.cache",
"celery.backends.redis",
]:
return None
LOGGER.debug("sending event to sentry", exc=exc_value, source_logger=event.get("logger", None))

View file

@ -481,6 +481,8 @@ class OutpostState:
def for_outpost(outpost: Outpost) -> list["OutpostState"]:
"""Get all states for an outpost"""
keys = cache.keys(f"{outpost.state_cache_prefix}_*")
if not keys:
return []
states = []
for key in keys:
instance_uid = key.replace(f"{outpost.state_cache_prefix}_", "")