outposts: improve error handling for outpost service connection state

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2022-01-10 19:44:13 +01:00
parent bd283c506d
commit 71dffb21a9
2 changed files with 14 additions and 6 deletions

View File

@ -77,8 +77,12 @@ def outpost_service_connection_state(connection_pk: Any):
cls = DockerClient
if isinstance(connection, KubernetesServiceConnection):
cls = KubernetesClient
with cls(connection) as client:
state = client.fetch_state()
try:
with cls(connection) as client:
state = client.fetch_state()
except ServiceConnectionInvalid as exc:
LOGGER.warning("Failed to get client status", exc=exc)
return
cache.set(connection.state_key, state, timeout=None)