Add config option for exposing HAProxy stats interface.

Change-Id: I41799835a4d59dd7d4e0c0becf0908eaab6281ae
Closes-Bug: #1710208
func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/147
This commit is contained in:
cjohnston 2019-12-06 18:34:53 +00:00 committed by Chris Johnston
parent 43a086bc6f
commit 8b6d16698a
4 changed files with 27 additions and 4 deletions

View File

@ -273,6 +273,11 @@ options:
description: |
Connect timeout configuration in ms for haproxy, used in HA
configurations. If not provided, default value of 9000ms is used.
haproxy-expose-stats:
type: boolean
default: False
description: |
If True, exposes stats interface externally.
enforce-ssl:
type: boolean
default: False

View File

@ -84,7 +84,8 @@ class HorizonHAProxyContext(OSContextGenerator):
'dash_insecure': [80, 70],
'dash_secure': [443, 433]
},
'prefer_ipv6': config('prefer-ipv6')
'prefer_ipv6': config('prefer-ipv6'),
'haproxy_expose_stats': config('haproxy-expose-stats')
}
return ctxt

View File

@ -34,7 +34,7 @@ defaults
{%- endif %}
listen stats
bind {{ local_host }}:{{ stat_port }}
bind {% if haproxy_expose_stats %}{{ haproxy_host }}{% else %}{{ local_host }}{% endif %}:{{ stat_port }}
mode http
stats enable
stats hide-version

View File

@ -697,7 +697,8 @@ class TestHorizonContexts(CharmTestCase):
{'units': {'openstack-dashboard-0': '10.5.0.1'},
'service_ports': {'dash_insecure': [80, 70],
'dash_secure': [443, 433]},
'prefer_ipv6': False})
'prefer_ipv6': False,
'haproxy_expose_stats': False})
_open.assert_called_with('/etc/default/haproxy', 'w')
self.assertTrue(_file.write.called)
self.get_relation_ip.assert_called_with('cluster')
@ -717,11 +718,27 @@ class TestHorizonContexts(CharmTestCase):
'openstack-dashboard-2': '10.5.0.3'},
'service_ports': {'dash_insecure': [80, 70],
'dash_secure': [443, 433]},
'prefer_ipv6': False})
'prefer_ipv6': False,
'haproxy_expose_stats': False})
_open.assert_called_with('/etc/default/haproxy', 'w')
self.assertTrue(_file.write.called)
self.get_relation_ip.assert_called_with('cluster')
def test_HorizonHAProxyContext_expose_stats(self):
self.test_config.set('haproxy-expose-stats', True)
self.relation_ids.return_value = []
self.local_unit.return_value = 'openstack-dashboard/0'
self.get_relation_ip.return_value = "10.5.0.1"
with patch_open() as (_open, _file):
self.assertEquals(horizon_contexts.HorizonHAProxyContext()(),
{'units': {'openstack-dashboard-0': '10.5.0.1'},
'service_ports': {'dash_insecure': [80, 70],
'dash_secure': [443, 433]},
'prefer_ipv6': False,
'haproxy_expose_stats': True})
_open.assert_called_with('/etc/default/haproxy', 'w')
self.assertTrue(_file.write.called)
def test_RouterSettingContext(self):
self.test_config.set('profile', 'cisco')
self.assertEqual(horizon_contexts.RouterSettingContext()(),