]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm/services/ingress: fixed keepalived config bug 57848/head
authorBernard Landon <bernard@lndn.ch>
Mon, 3 Jun 2024 15:53:55 +0000 (17:53 +0200)
committerBernard Landon <bernard@lndn.ch>
Sat, 15 Jun 2024 10:12:02 +0000 (10:12 +0000)
In some special conditions, such as ingress service reconfiguration,
cepham would list the network IPs and pick the VIP as the unicast IP of the peer.
It would then generate buggy keepalived config causing service misbehavior.

Fixes: https://tracker.ceph.com/issues/66507
Signed-off-by: Bernard Landon <bernard@lndn.ch>
src/pybind/mgr/cephadm/services/ingress.py
src/pybind/mgr/cephadm/tests/test_services.py

index e46fab732edb2486f79796c40cbb83364153b850..23639f75c7305a3e3d47246de9d6ac33cd29e898 100644 (file)
@@ -260,7 +260,10 @@ class IngressService(CephService):
             for subnet, ifaces in self.mgr.cache.networks.get(host, {}).items():
                 if ifaces and ipaddress.ip_address(bare_ip) in ipaddress.ip_network(subnet):
                     interface = list(ifaces.keys())[0]
-                    host_ip = ifaces[interface][0]
+                    for ip_addr in ifaces[interface]:
+                        if ip_addr != str(bare_ip):
+                            host_ip = ip_addr
+                            break
                     logger.info(
                         f'{bare_ip} is in {subnet} on {host} interface {interface}'
                     )
@@ -270,7 +273,10 @@ class IngressService(CephService):
                 for subnet, ifaces in self.mgr.cache.networks.get(host, {}).items():
                     if subnet in spec.virtual_interface_networks:
                         interface = list(ifaces.keys())[0]
-                        host_ip = ifaces[interface][0]
+                        for ip_addr in ifaces[interface]:
+                            if ip_addr != str(bare_ip):
+                                host_ip = ip_addr
+                                break
                         logger.info(
                             f'{spec.virtual_ip} will be configured on {host} interface '
                             f'{interface} (which is in subnet {subnet})'
index 5b484d094fb0ce3d319a8a814705e5a50420b847..73a49f2f900114a69cdeeb6ab7fc93e0985ca32b 100644 (file)
@@ -1846,7 +1846,10 @@ class TestIngressService:
         with with_host(cephadm_module, 'test', addr='1.2.3.7'):
             cephadm_module.cache.update_host_networks('test', {
                 '1.2.3.0/24': {
-                    'if0': ['1.2.3.4']
+                    'if0': [
+                        '1.2.3.4',  # simulate already assigned VIP
+                        '1.2.3.1',  # simulate interface IP
+                    ]
                 }
             })
 
@@ -1894,7 +1897,7 @@ class TestIngressService:
                                 'auth_type PASS\n      '
                                 'auth_pass 12345\n  '
                                 '}\n  '
-                                'unicast_src_ip 1.2.3.4\n  '
+                                'unicast_src_ip 1.2.3.1\n  '
                                 'unicast_peer {\n  '
                                 '}\n  '
                                 'virtual_ipaddress {\n    '