outposts: improve messaging from controller on k8s
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
4e9176ed2e
commit
ef63e35ad2
|
@ -2,10 +2,9 @@
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
from kubernetes.client import OpenApiException
|
|
||||||
from kubernetes.client.api_client import ApiClient
|
from kubernetes.client.api_client import ApiClient
|
||||||
|
from kubernetes.client.exceptions import ApiException
|
||||||
from structlog.testing import capture_logs
|
from structlog.testing import capture_logs
|
||||||
from urllib3.exceptions import HTTPError
|
|
||||||
from yaml import dump_all
|
from yaml import dump_all
|
||||||
|
|
||||||
from authentik.outposts.controllers.base import BaseController, ControllerException
|
from authentik.outposts.controllers.base import BaseController, ControllerException
|
||||||
|
@ -43,8 +42,8 @@ class KubernetesController(BaseController):
|
||||||
reconciler = self.reconcilers[reconcile_key](self)
|
reconciler = self.reconcilers[reconcile_key](self)
|
||||||
reconciler.up()
|
reconciler.up()
|
||||||
|
|
||||||
except (OpenApiException, HTTPError) as exc:
|
except ApiException as exc:
|
||||||
raise ControllerException from exc
|
raise ControllerException(str(exc)) from exc
|
||||||
|
|
||||||
def up_with_logs(self) -> list[str]:
|
def up_with_logs(self) -> list[str]:
|
||||||
try:
|
try:
|
||||||
|
@ -55,8 +54,8 @@ class KubernetesController(BaseController):
|
||||||
reconciler.up()
|
reconciler.up()
|
||||||
all_logs += [f"{reconcile_key.title()}: {x['event']}" for x in logs]
|
all_logs += [f"{reconcile_key.title()}: {x['event']}" for x in logs]
|
||||||
return all_logs
|
return all_logs
|
||||||
except (OpenApiException, HTTPError) as exc:
|
except ApiException as exc:
|
||||||
raise ControllerException from exc
|
raise ControllerException(str(exc)) from exc
|
||||||
|
|
||||||
def down(self):
|
def down(self):
|
||||||
try:
|
try:
|
||||||
|
@ -64,8 +63,8 @@ class KubernetesController(BaseController):
|
||||||
reconciler = self.reconcilers[reconcile_key](self)
|
reconciler = self.reconcilers[reconcile_key](self)
|
||||||
reconciler.down()
|
reconciler.down()
|
||||||
|
|
||||||
except OpenApiException as exc:
|
except ApiException as exc:
|
||||||
raise ControllerException from exc
|
raise ControllerException(str(exc)) from exc
|
||||||
|
|
||||||
def get_static_deployment(self) -> str:
|
def get_static_deployment(self) -> str:
|
||||||
documents = []
|
documents = []
|
||||||
|
|
Reference in New Issue