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 = []