]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: fix haproxy monitoring endpoint 55970/head
authorRedouane Kachach <rkachach@redhat.com>
Mon, 14 Nov 2022 17:49:42 +0000 (18:49 +0100)
committerAdam King <adking@redhat.com>
Tue, 5 Mar 2024 16:02:54 +0000 (11:02 -0500)
Fixes: https://tracker.ceph.com/issues/58021
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
(cherry picked from commit 9636d9467f7bbcbda31da7809065000c49326dca)

Conflicts:
src/pybind/mgr/cephadm/tests/test_services.py

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 01c51303fa5a20cf952ec9bce864c017907662cd..f6d647f10cde2db001835e653f496e9d94f6d9eb 100644 (file)
@@ -164,6 +164,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',
             {
@@ -176,6 +177,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 = {
@@ -277,7 +279,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 6d64c63634587a5e4f23cad2ac7b7979e5462838..a529798e739d77d4ecbe3ed3d22729901c1a1be4 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 d51ac047cb07c251f9e641e7f069599ec68e08d6..6b4c65babf68f6530aace6a14f7487773f00574d 100644 (file)
@@ -1105,7 +1105,7 @@ class TestIngressService:
                         'frontend stats\n'
                         '    mode http\n'
                         '    bind 192.168.122.100:9049\n'
-                        '    bind localhost:9049\n'
+                        '    bind host1:9049\n'
                         '    stats enable\n'
                         '    stats uri /stats\n'
                         '    stats refresh 10s\n'
@@ -1155,7 +1155,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']
@@ -1187,7 +1187,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    '
@@ -1253,7 +1253,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    '
@@ -1268,7 +1268,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'
                         }
                 }
 
@@ -1310,7 +1310,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    '
@@ -1376,7 +1376,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    '
@@ -1403,7 +1403,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.1']
@@ -1436,7 +1436,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    '
@@ -1502,7 +1502,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    '
@@ -1517,7 +1517,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'
                         }
                 }
 
@@ -1570,7 +1570,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.1:8999/health"\n    '
                                     'weight -20\n    '
                                     'interval 2\n    '
                                     'rise 2\n    '