diff options
author | Adam King <47704447+adk3798@users.noreply.github.com> | 2024-03-19 14:41:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-19 14:41:54 +0100 |
commit | 106ae8f73e493b244423545971f4f48b4c1a8e90 (patch) | |
tree | d1d3ad798fa539d4a351493c34d05087bfff694c /src | |
parent | Merge pull request #56189 from rhcs-dashboard/fix-64913-main (diff) | |
parent | cephadm: adjust the ingress ha proxy health check interval (diff) | |
download | ceph-106ae8f73e493b244423545971f4f48b4c1a8e90.tar.xz ceph-106ae8f73e493b244423545971f4f48b4c1a8e90.zip |
Merge pull request #52760 from thotz/add-healthchecker-timeout-haproxy
cephadm: adjust the ingress ha proxy health check interval
Reviewed-by: Adam King <adking@redhat.com>
Diffstat (limited to 'src')
4 files changed, 15 insertions, 4 deletions
diff --git a/src/pybind/mgr/cephadm/services/ingress.py b/src/pybind/mgr/cephadm/services/ingress.py index 55be3045466..5edd2517dc0 100644 --- a/src/pybind/mgr/cephadm/services/ingress.py +++ b/src/pybind/mgr/cephadm/services/ingress.py @@ -187,6 +187,7 @@ class IngressService(CephService): 'monitor_port': daemon_spec.ports[1] if daemon_spec.ports else spec.monitor_port, 'local_host_ip': host_ip, 'default_server_opts': server_opts, + 'health_check_interval': spec.health_check_interval or '2s', } ) config_files = { diff --git a/src/pybind/mgr/cephadm/templates/services/ingress/haproxy.cfg.j2 b/src/pybind/mgr/cephadm/templates/services/ingress/haproxy.cfg.j2 index c114a8cba11..9a0309ab409 100644 --- a/src/pybind/mgr/cephadm/templates/services/ingress/haproxy.cfg.j2 +++ b/src/pybind/mgr/cephadm/templates/services/ingress/haproxy.cfg.j2 @@ -74,7 +74,7 @@ backend backend balance static-rr option httpchk HEAD / HTTP/1.0 {% for server in servers %} - server {{ server.name }} {{ server.ip }}:{{ server.port }} check weight 100 + server {{ server.name }} {{ server.ip }}:{{ server.port }} check weight 100 inter {{ health_check_interval }} {% endfor %} {% endif %} {% if mode == 'tcp' %} diff --git a/src/pybind/mgr/cephadm/tests/test_services.py b/src/pybind/mgr/cephadm/tests/test_services.py index 30b121cc372..8998d6f238e 100644 --- a/src/pybind/mgr/cephadm/tests/test_services.py +++ b/src/pybind/mgr/cephadm/tests/test_services.py @@ -1854,7 +1854,7 @@ class TestIngressService: 'balance static-rr\n ' 'option httpchk HEAD / HTTP/1.0\n ' 'server ' - + haproxy_generated_conf[1][0] + ' 1.2.3.7:80 check weight 100\n' + + haproxy_generated_conf[1][0] + ' 1.2.3.7:80 check weight 100 inter 2s\n' } } @@ -1979,7 +1979,7 @@ class TestIngressService: 'balance static-rr\n ' 'option httpchk HEAD / HTTP/1.0\n ' 'server ' - + haproxy_generated_conf[1][0] + ' 1::4:443 check weight 100\n' + + haproxy_generated_conf[1][0] + ' 1::4:443 check weight 100 inter 2s\n' } } @@ -2103,7 +2103,7 @@ class TestIngressService: 'balance static-rr\n ' 'option httpchk HEAD / HTTP/1.0\n ' 'server ' - + haproxy_generated_conf[1][0] + ' 1.2.3.7:80 check weight 100\n' + + haproxy_generated_conf[1][0] + ' 1.2.3.7:80 check weight 100 inter 2s\n' } } diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index db7beac4dc2..7edd14ce28e 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -1463,6 +1463,7 @@ class IngressSpec(ServiceSpec): extra_container_args: Optional[GeneralArgList] = None, extra_entrypoint_args: Optional[GeneralArgList] = None, custom_configs: Optional[List[CustomConfig]] = None, + health_check_interval: Optional[str] = None, ): assert service_type == 'ingress' @@ -1495,6 +1496,8 @@ class IngressSpec(ServiceSpec): self.ssl = ssl self.keepalive_only = keepalive_only self.enable_haproxy_protocol = enable_haproxy_protocol + self.health_check_interval = health_check_interval.strip( + ) if health_check_interval else None def get_port_start(self) -> List[int]: ports = [] @@ -1525,6 +1528,13 @@ class IngressSpec(ServiceSpec): if self.virtual_ip is not None and self.virtual_ips_list is not None: raise SpecValidationError( 'Cannot add ingress: Single and multiple virtual IPs specified') + if self.health_check_interval: + valid_units = ['s', 'm', 'h'] + m = re.search(rf"^(\d+)({'|'.join(valid_units)})$", self.health_check_interval) + if not m: + raise SpecValidationError( + f'Cannot add ingress: Invalid health_check_interval specified. ' + f'Valid units are: {valid_units}') yaml.add_representer(IngressSpec, ServiceSpec.yaml_representer) |