From 8560c2bf2acabc027ae9380ba255a025152b3c9e 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 | 2 -- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/salt/_modules/metalk8s_network.py b/salt/_modules/metalk8s_network.py index bd839010a1..b8fd3bed5d 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()) - ) + config_control_plane_ip = __salt__["metalk8s_network.get_control_plane_ingress_ip"]() + mine_control_plane_ips = list(mine_ret.values()) + if config_control_plane_ip in mine_control_plane_ips: + mine_control_plane_ips.remove(config_control_plane_ip) + + return [config_control_plane_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..ca48c0c4e1 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