Enable HAProxy HTTP Health Checks

Ceph radosgw supports [0] the swift health check endpoint
"/swift/healthcheck". This change adds the haproxy
configuration [1] necessary to take the response of "GET
/swift/healthcheck" into account when determining the health
of a radosgw service.

For testing, I verified that:
- HAProxy starts and responds to requests normally with this
  configuration.
- Servers with status != 2xx or 3xx are removed from the
  backend.
- Servers that take too long to respond are also removed
  from the backend. The default timeout value is 2s.

[0] https://tracker.ceph.com/issues/11682
[1] https://www.haproxy.com/documentation/hapee/2-0r1/onepage/#4.2-option%20httpchk

Closes-Bug: 1946280
Change-Id: I82634255ca3423fec3fc15c1e714dcb31db5da7a
(cherry picked from commit 31a4584169)
This commit is contained in:
Cornellius Metto 2021-11-11 16:03:13 +00:00 committed by Alex Kavanagh
parent 7da070b941
commit 3c7f468b0c
3 changed files with 21 additions and 3 deletions

View File

@ -22,6 +22,7 @@ from charmhelpers.contrib.openstack import context
from charmhelpers.contrib.hahelpers.cluster import (
determine_api_port,
determine_apache_port,
https,
)
from charmhelpers.core.host import (
cmp_pkgrevno,
@ -68,12 +69,13 @@ class HAProxyContext(context.HAProxyContext):
def __call__(self):
ctxt = super(HAProxyContext, self).__call__()
port = utils.listen_port()
service = 'cephradosgw-server'
# Apache ports
a_cephradosgw_api = determine_apache_port(port, singlenode_mode=True)
port_mapping = {
'cephradosgw-server': [port, a_cephradosgw_api]
service: [port, a_cephradosgw_api]
}
ctxt['cephradosgw_bind_port'] = determine_api_port(
@ -82,7 +84,16 @@ class HAProxyContext(context.HAProxyContext):
)
# for haproxy.conf
backend_options = {
service: [{
'option': 'httpchk GET /swift/healthcheck',
}]
}
ctxt['service_ports'] = port_mapping
ctxt['backend_options'] = backend_options
ctxt['https'] = https()
return ctxt

View File

@ -39,7 +39,10 @@ oslo.utils<=3.41.0;python_version<'3.6'
coverage>=4.5.2
pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking)
git+https://github.com/openstack-charmers/zaza.git@stable/wallaby#egg=zaza
git+https://github.com/openstack-charmers/zaza-openstack-tests.git@stable/wallaby#egg=zaza.openstack
#git+https://github.com/openstack-charmers/zaza-openstack-tests.git@stable/wallaby#egg=zaza.openstack
# DO NOT MERGE with the following lines
# Test the pyopenssl < 22.0.0 and cryptography 3.3.2 combination
git+https://github.com/ajkavanagh/zaza-openstack-tests.git@stable-wallaby-pyopenssl#egg=zaza.openstack
# Needed for charm-glance:
git+https://opendev.org/openstack/tempest.git#egg=tempest;python_version>='3.8'

View File

@ -63,7 +63,11 @@ class HAProxyContextTests(CharmTestCase):
self.determine_api_port.return_value = 70
expect = {
'cephradosgw_bind_port': 70,
'service_ports': {'cephradosgw-server': [80, 70]}
'service_ports': {'cephradosgw-server': [80, 70]},
'backend_options': {'cephradosgw-server': [{
'option': 'httpchk GET /swift/healthcheck',
}]},
'https': False
}
self.assertEqual(expect, haproxy_context())