Add support for HAProxy L7 checks
This change add several configuration options to enable HTTP checks to the HAProxy configuration, instead of the default TCP connection checks (which continue to be the default) Closes-Bug: #1880610 Change-Id: I81d7fd67029dd5025f95b41d788b03ce4b6038bb
This commit is contained in:
parent
fbedaf36bd
commit
96a2bb3af9
@ -38,6 +38,7 @@ from charmhelpers.contrib.openstack.context import (
|
|||||||
from charmhelpers.contrib.hahelpers.cluster import (
|
from charmhelpers.contrib.hahelpers.cluster import (
|
||||||
determine_apache_port,
|
determine_apache_port,
|
||||||
determine_api_port,
|
determine_api_port,
|
||||||
|
https,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.contrib.openstack.utils import (
|
from charmhelpers.contrib.openstack.utils import (
|
||||||
@ -402,14 +403,24 @@ class HAProxyContext(OSContextGenerator):
|
|||||||
specific to this charm.
|
specific to this charm.
|
||||||
Also used to extend glance-api.conf context with correct bind_port
|
Also used to extend glance-api.conf context with correct bind_port
|
||||||
'''
|
'''
|
||||||
|
service = 'glance_api'
|
||||||
haproxy_port = 9292
|
haproxy_port = 9292
|
||||||
apache_port = determine_apache_port(9292, singlenode_mode=True)
|
apache_port = determine_apache_port(9292, singlenode_mode=True)
|
||||||
api_port = determine_api_port(9292, singlenode_mode=True)
|
api_port = determine_api_port(9292, singlenode_mode=True)
|
||||||
|
|
||||||
|
backend_options = {
|
||||||
|
service: [{
|
||||||
|
'option': 'httpchk GET /healthcheck',
|
||||||
|
'http-check': 'expect status 200',
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
ctxt = {
|
ctxt = {
|
||||||
'service_ports': {'glance_api': [haproxy_port, apache_port]},
|
'service_ports': {service: [haproxy_port, apache_port]},
|
||||||
'bind_port': api_port,
|
'bind_port': api_port,
|
||||||
}
|
}
|
||||||
|
ctxt['backend_options'] = backend_options
|
||||||
|
ctxt['https'] = https()
|
||||||
return ctxt
|
return ctxt
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@ TO_PATCH = [
|
|||||||
'relation_ids',
|
'relation_ids',
|
||||||
'is_relation_made',
|
'is_relation_made',
|
||||||
'service_name',
|
'service_name',
|
||||||
'determine_apache_port',
|
|
||||||
'determine_api_port',
|
|
||||||
'os_release',
|
'os_release',
|
||||||
'juju_log',
|
'juju_log',
|
||||||
]
|
]
|
||||||
@ -604,3 +602,28 @@ class TestGlanceContexts(CharmTestCase):
|
|||||||
ctxt = contexts.GlanceIPv6Context()
|
ctxt = contexts.GlanceIPv6Context()
|
||||||
self.assertEqual(ctxt(), {'bind_host': '0.0.0.0',
|
self.assertEqual(ctxt(), {'bind_host': '0.0.0.0',
|
||||||
'registry_host': '0.0.0.0'})
|
'registry_host': '0.0.0.0'})
|
||||||
|
|
||||||
|
@patch('charmhelpers.contrib.hahelpers.cluster.https')
|
||||||
|
@patch('glance_contexts.https')
|
||||||
|
def test_ctxt(self, mock_https, mock_ch_https):
|
||||||
|
bind_port = 9282
|
||||||
|
for https_mode in [False, True]:
|
||||||
|
mock_https.return_value = https_mode
|
||||||
|
mock_ch_https.return_value = https_mode
|
||||||
|
if https_mode:
|
||||||
|
bind_port = 9272
|
||||||
|
haproxy_context = contexts.HAProxyContext()
|
||||||
|
expected = {
|
||||||
|
"service_ports": {"glance_api": [9292, 9282]},
|
||||||
|
"bind_port": bind_port,
|
||||||
|
"backend_options": {
|
||||||
|
"glance_api": [
|
||||||
|
{
|
||||||
|
'option': 'httpchk GET /healthcheck',
|
||||||
|
'http-check': 'expect status 200',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"https": https_mode,
|
||||||
|
}
|
||||||
|
self.assertEqual(expected, haproxy_context())
|
||||||
|
Loading…
Reference in New Issue
Block a user