} 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',
{
'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 = {
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 = []
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']
'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 '
'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 '
'\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 '
'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'
}
}
'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 '
'\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 '
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']
'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 '
'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 '
'\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 '
'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'
}
}