From 91227b1e961238d02759ec4e94f5e8197b62282d Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 8 Feb 2022 17:22:54 +0100 Subject: [PATCH] outposts: fix service reconciler re-creating services closes #2095 Signed-off-by: Jens Langhammer --- authentik/outposts/controllers/k8s/utils.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/authentik/outposts/controllers/k8s/utils.py b/authentik/outposts/controllers/k8s/utils.py index eb9430251..2605d46b7 100644 --- a/authentik/outposts/controllers/k8s/utils.py +++ b/authentik/outposts/controllers/k8s/utils.py @@ -16,13 +16,22 @@ def get_namespace() -> str: return "default" +def compare_port(current: V1ServicePort, reference: V1ServicePort) -> bool: + """Compare a single port""" + if current.name != reference.name: + return False + # We only care about the target port + if current.target_port != reference.target_port: + return False + if current.protocol != reference.protocol: + return False + return True + + def compare_ports(current: list[V1ServicePort], reference: list[V1ServicePort]): """Compare ports of a list""" if len(current) != len(reference): raise NeedsRecreate() for port in reference: - # We don't need to compare node_ports - # https://github.com/goauthentik/authentik/issues/2095#issuecomment-1020674326 - port.node_port = None - if port not in current: + if not any(compare_port(port, current_port) for current_port in current): raise NeedsRecreate()