outposts: improve messaging from controller on k8s

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-06 20:07:29 +02:00
parent 4e9176ed2e
commit ef63e35ad2

View file

@ -2,10 +2,9 @@
from io import StringIO
from typing import Type
from kubernetes.client import OpenApiException
from kubernetes.client.api_client import ApiClient
from kubernetes.client.exceptions import ApiException
from structlog.testing import capture_logs
from urllib3.exceptions import HTTPError
from yaml import dump_all
from authentik.outposts.controllers.base import BaseController, ControllerException
@ -43,8 +42,8 @@ class KubernetesController(BaseController):
reconciler = self.reconcilers[reconcile_key](self)
reconciler.up()
except (OpenApiException, HTTPError) as exc:
raise ControllerException from exc
except ApiException as exc:
raise ControllerException(str(exc)) from exc
def up_with_logs(self) -> list[str]:
try:
@ -55,8 +54,8 @@ class KubernetesController(BaseController):
reconciler.up()
all_logs += [f"{reconcile_key.title()}: {x['event']}" for x in logs]
return all_logs
except (OpenApiException, HTTPError) as exc:
raise ControllerException from exc
except ApiException as exc:
raise ControllerException(str(exc)) from exc
def down(self):
try:
@ -64,8 +63,8 @@ class KubernetesController(BaseController):
reconciler = self.reconcilers[reconcile_key](self)
reconciler.down()
except OpenApiException as exc:
raise ControllerException from exc
except ApiException as exc:
raise ControllerException(str(exc)) from exc
def get_static_deployment(self) -> str:
documents = []