From b713dcc289670ef970830e72aac7fcdd075ab9e6 Mon Sep 17 00:00:00 2001 From: Ayoub Nasr Date: Mon, 2 Sep 2024 16:15:30 +0200 Subject: [PATCH] Do not show duplicated IP in CP ingress external IPs list --- salt/_modules/metalk8s_network.py | 9 ++++++--- salt/tests/unit/modules/files/test_metalk8s_network.yaml | 3 --- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/salt/_modules/metalk8s_network.py b/salt/_modules/metalk8s_network.py index bd839010a1..8eeed83675 100644 --- a/salt/_modules/metalk8s_network.py +++ b/salt/_modules/metalk8s_network.py @@ -308,6 +308,9 @@ def get_control_plane_ingress_external_ips(): f"Unable to get master Control Plane IPs: {mine_ret}" ) - return [__salt__["metalk8s_network.get_control_plane_ingress_ip"]()] + sorted( - list(mine_ret.values()) - ) + control_plane_ingress_ip = __salt__["metalk8s_network.get_control_plane_ingress_ip"]() + mine_control_plane_ips = list(mine_ret.values()) + if control_plane_ingress_ip in mine_control_plane_ips: + mine_control_plane_ips.remove(control_plane_ingress_ip) + + return [control_plane_ingress_ip] + sorted(mine_control_plane_ips) diff --git a/salt/tests/unit/modules/files/test_metalk8s_network.yaml b/salt/tests/unit/modules/files/test_metalk8s_network.yaml index d3674cbca5..a805ccd6c2 100644 --- a/salt/tests/unit/modules/files/test_metalk8s_network.yaml +++ b/salt/tests/unit/modules/files/test_metalk8s_network.yaml @@ -263,7 +263,6 @@ get_control_plane_ingress_external_ips: bootstrap: 1.1.1.1 result: - 1.1.1.1 - - 1.1.1.1 # 2. Nominal single node (using non-bootstrap IP) - cp_ingress_ip_ret: 1.1.1.4 @@ -284,7 +283,6 @@ get_control_plane_ingress_external_ips: node-1: 1.1.1.2 node-2: 1.1.1.3 result: - - 1.1.1.1 - 1.1.1.1 - 1.1.1.2 - 1.1.1.3 @@ -318,7 +316,6 @@ get_control_plane_ingress_external_ips: result: - 1.1.1.2 - 1.1.1.1 - - 1.1.1.2 - 1.1.1.3 # 6. Multi node, one master node not yet in mine