]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: fix haproxy monitoring endpoint 48880/head
authorRedouane Kachach <rkachach@redhat.com>
Mon, 14 Nov 2022 17:49:42 +0000 (18:49 +0100)
committerRedouane Kachach <rkachach@redhat.com>
Mon, 23 Jan 2023 09:12:51 +0000 (10:12 +0100)
Fixes: https://tracker.ceph.com/issues/58021
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
src/pybind/mgr/cephadm/services/ingress.py
src/pybind/mgr/cephadm/templates/services/ingress/haproxy.cfg.j2
src/pybind/mgr/cephadm/tests/test_services.py

index d53d719c287d3840a49e501f2bd42108a3e27c61..5e4145d58065ee45c00756168ee5e9f08ccde533 100644 (file)
@@ -123,6 +123,7 @@ class IngressService(CephService):
                 } for d in daemons if d.ports
             ]
 
+        host_ip = daemon_spec.ip or self.mgr.inventory.get_addr(daemon_spec.host)
         haproxy_conf = self.mgr.template.render(
             'services/ingress/haproxy.cfg.j2',
             {
@@ -135,6 +136,7 @@ class IngressService(CephService):
                 'ip': "*" if spec.virtual_ips_list else str(spec.virtual_ip).split('/')[0] or daemon_spec.ip or '*',
                 'frontend_port': daemon_spec.ports[0] if daemon_spec.ports else spec.frontend_port,
                 'monitor_port': daemon_spec.ports[1] if daemon_spec.ports else spec.monitor_port,
+                'local_host_ip': host_ip
             }
         )
         config_files = {
@@ -239,7 +241,8 @@ class IngressService(CephService):
                 if d.daemon_type == 'haproxy':
                     assert d.ports
                     port = d.ports[1]   # monitoring port
-                    script = f'/usr/bin/curl {build_url(scheme="http", host=d.ip or "localhost", port=port)}/health'
+                    host_ip = d.ip or self.mgr.inventory.get_addr(d.hostname)
+                    script = f'/usr/bin/curl {build_url(scheme="http", host=host_ip, port=port)}/health'
         assert script
 
         states = []
index 025f081f9e1efac3c2e4e0745ce464e2b3806a41..060af25dff54c4295fe43e2dedb15ea972f7f3b2 100644 (file)
@@ -48,7 +48,7 @@ defaults
 frontend stats
     mode http
     bind {{ ip }}:{{ monitor_port }}
-    bind localhost:{{ monitor_port }}
+    bind {{ local_host_ip }}:{{ monitor_port }}
     stats enable
     stats uri /stats
     stats refresh 10s
index 41bbc13ee44ce705425df5dd18ca47390a80b4ba..8789f5e368e2df5c17b64eeead58e861c5afdeaf 100644 (file)
@@ -903,7 +903,7 @@ class TestIngressService:
     def test_ingress_config(self, _run_cephadm, cephadm_module: CephadmOrchestrator):
         _run_cephadm.side_effect = async_side_effect(('{}', '', 0))
 
-        with with_host(cephadm_module, 'test'):
+        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/32']
@@ -935,7 +935,7 @@ class TestIngressService:
                             'keepalived.conf':
                                 '# This file is generated by cephadm.\n'
                                 'vrrp_script check_backend {\n    '
-                                'script "/usr/bin/curl http://localhost:8999/health"\n    '
+                                'script "/usr/bin/curl http://1.2.3.7:8999/health"\n    '
                                 'weight -20\n    '
                                 'interval 2\n    '
                                 'rise 2\n    '
@@ -950,7 +950,7 @@ class TestIngressService:
                                 'auth_type PASS\n      '
                                 'auth_pass 12345\n  '
                                 '}\n  '
-                                'unicast_src_ip 1::4\n  '
+                                'unicast_src_ip 1.2.3.7\n  '
                                 'unicast_peer {\n  '
                                 '}\n  '
                                 'virtual_ipaddress {\n    '
@@ -1001,7 +1001,7 @@ class TestIngressService:
                                 '\nfrontend stats\n    '
                                 'mode http\n    '
                                 'bind 1.2.3.4:8999\n    '
-                                'bind localhost:8999\n    '
+                                'bind 1.2.3.7:8999\n    '
                                 'stats enable\n    '
                                 'stats uri /stats\n    '
                                 'stats refresh 10s\n    '
@@ -1016,7 +1016,7 @@ class TestIngressService:
                                 'balance static-rr\n    '
                                 'option httpchk HEAD / HTTP/1.0\n    '
                                 'server '
-                                + haproxy_generated_conf[1][0] + ' 1::4:80 check weight 100\n'
+                                + haproxy_generated_conf[1][0] + ' 1.2.3.7:80 check weight 100\n'
                         }
                 }
 
@@ -1058,7 +1058,7 @@ class TestIngressService:
                             'keepalived.conf':
                                 '# This file is generated by cephadm.\n'
                                 'vrrp_script check_backend {\n    '
-                                'script "/usr/bin/curl http://localhost:8999/health"\n    '
+                                'script "/usr/bin/curl http://[1::4]:8999/health"\n    '
                                 'weight -20\n    '
                                 'interval 2\n    '
                                 'rise 2\n    '
@@ -1124,7 +1124,7 @@ class TestIngressService:
                                 '\nfrontend stats\n    '
                                 'mode http\n    '
                                 'bind 1.2.3.4:8999\n    '
-                                'bind localhost:8999\n    '
+                                'bind 1::4:8999\n    '
                                 'stats enable\n    '
                                 'stats uri /stats\n    '
                                 'stats refresh 10s\n    '
@@ -1151,7 +1151,7 @@ class TestIngressService:
     def test_ingress_config_multi_vips(self, _run_cephadm, cephadm_module: CephadmOrchestrator):
         _run_cephadm.side_effect = async_side_effect(('{}', '', 0))
 
-        with with_host(cephadm_module, 'test'):
+        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/32']
@@ -1184,7 +1184,7 @@ class TestIngressService:
                             'keepalived.conf':
                                 '# This file is generated by cephadm.\n'
                                 'vrrp_script check_backend {\n    '
-                                'script "/usr/bin/curl http://localhost:8999/health"\n    '
+                                'script "/usr/bin/curl http://1.2.3.7:8999/health"\n    '
                                 'weight -20\n    '
                                 'interval 2\n    '
                                 'rise 2\n    '
@@ -1199,7 +1199,7 @@ class TestIngressService:
                                 'auth_type PASS\n      '
                                 'auth_pass 12345\n  '
                                 '}\n  '
-                                'unicast_src_ip 1::4\n  '
+                                'unicast_src_ip 1.2.3.7\n  '
                                 'unicast_peer {\n  '
                                 '}\n  '
                                 'virtual_ipaddress {\n    '
@@ -1250,7 +1250,7 @@ class TestIngressService:
                                 '\nfrontend stats\n    '
                                 'mode http\n    '
                                 'bind *:8999\n    '
-                                'bind localhost:8999\n    '
+                                'bind 1.2.3.7:8999\n    '
                                 'stats enable\n    '
                                 'stats uri /stats\n    '
                                 'stats refresh 10s\n    '
@@ -1265,7 +1265,7 @@ class TestIngressService:
                                 'balance static-rr\n    '
                                 'option httpchk HEAD / HTTP/1.0\n    '
                                 'server '
-                                + haproxy_generated_conf[1][0] + ' 1::4:80 check weight 100\n'
+                                + haproxy_generated_conf[1][0] + ' 1.2.3.7:80 check weight 100\n'
                         }
                 }