From ef63e35ad2fbebcca0b7fd947cd99cba83f9d436 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 6 May 2021 20:07:29 +0200 Subject: [PATCH] outposts: improve messaging from controller on k8s Signed-off-by: Jens Langhammer --- authentik/outposts/controllers/kubernetes.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/authentik/outposts/controllers/kubernetes.py b/authentik/outposts/controllers/kubernetes.py index 2489f203d..1b6d3e58d 100644 --- a/authentik/outposts/controllers/kubernetes.py +++ b/authentik/outposts/controllers/kubernetes.py @@ -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 = []