Merge "Enable HAProxy HTTP Health Checks"

This commit is contained in:
Zuul 2022-03-04 16:15:19 +00:00 committed by Gerrit Code Review
commit 88d1f4b0a5
2 changed files with 17 additions and 2 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

@ -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())