From 401e7255062ef45e2c15d7f30dcddc3822cb67ed Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 22 Mar 2021 14:30:42 -0500 Subject: [PATCH] mgr/cephadm: ha-rgw: use correct port The DaemonDescription includes the port that RGW is bound to; use that in the haproxy configuration. Signed-off-by: Sage Weil --- src/pybind/mgr/cephadm/services/ha_rgw.py | 8 ++++++-- .../mgr/cephadm/templates/services/haproxy/haproxy.cfg.j2 | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/cephadm/services/ha_rgw.py b/src/pybind/mgr/cephadm/services/ha_rgw.py index 488088f1d54f9..6f7abad40c52e 100644 --- a/src/pybind/mgr/cephadm/services/ha_rgw.py +++ b/src/pybind/mgr/cephadm/services/ha_rgw.py @@ -13,9 +13,10 @@ class HA_RGWService(CephService): TYPE = 'ha-rgw' class rgw_server(): - def __init__(self, hostname: str, address: str): + def __init__(self, hostname: str, address: str, port: int): self.name = hostname self.ip = address + self.port = port def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonDeploySpec: assert daemon_spec.daemon_type == 'haproxy' or daemon_spec.daemon_type == 'keepalived' @@ -68,7 +69,10 @@ class HA_RGWService(CephService): for daemon in rgw_daemons: assert daemon.hostname is not None rgw_servers.append(self.rgw_server( - daemon.name(), resolve_ip(daemon.hostname))) + daemon.name(), + resolve_ip(daemon.hostname), + daemon.ports[0] if daemon.ports else 80 + )) # virtual ip address cannot have netmask attached when passed to haproxy config # since the port is added to the end and something like 123.123.123.10/24:8080 is invalid diff --git a/src/pybind/mgr/cephadm/templates/services/haproxy/haproxy.cfg.j2 b/src/pybind/mgr/cephadm/templates/services/haproxy/haproxy.cfg.j2 index 4b3b4cf0782a0..3cc51278f1c90 100644 --- a/src/pybind/mgr/cephadm/templates/services/haproxy/haproxy.cfg.j2 +++ b/src/pybind/mgr/cephadm/templates/services/haproxy/haproxy.cfg.j2 @@ -62,5 +62,5 @@ backend rgw-backend balance static-rr option httpchk HEAD / HTTP/1.0 {% for server in rgw_servers %} - server {{ server.name }} {{ server.ip }}:80 check weight 100 + server {{ server.name }} {{ server.ip }}:{{ server.port }} check weight 100 {% endfor %} -- 2.39.5