Skip to content

Commit

Permalink
Add 'heartbeat_timeout_threshold` option
Browse files Browse the repository at this point in the history
This change adds the `heartbeat_timeout_threshold` option to the
`oslo_messaging_rabbit` section.

It also cleans some uses of `conf.get()` to make use of the default
`scope=None` parameter.

Closes-Bug: #1918673

Signed-off-by: Nicolas Bock <[email protected]>
  • Loading branch information
nicolasbock committed Mar 15, 2021
1 parent 29c9c2c commit c706f49
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
21 changes: 6 additions & 15 deletions charmhelpers/contrib/openstack/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,22 +751,13 @@ def __call__(self):
ctxt['oslo_messaging_flags'] = config_flags_parser(
oslo_messaging_flags)

oslo_messaging_driver = conf.get(
ctxt['oslo_messaging_driver'] = conf.get(
'oslo-messaging-driver', DEFAULT_OSLO_MESSAGING_DRIVER)
if oslo_messaging_driver:
ctxt['oslo_messaging_driver'] = oslo_messaging_driver

notification_format = conf.get('notification-format', None)
if notification_format:
ctxt['notification_format'] = notification_format

notification_topics = conf.get('notification-topics', None)
if notification_topics:
ctxt['notification_topics'] = notification_topics

send_notifications_to_logs = conf.get('send-notifications-to-logs', None)
if send_notifications_to_logs:
ctxt['send_notifications_to_logs'] = send_notifications_to_logs
ctxt['notification_format'] = conf.get('notification-format')
ctxt['notification_topics'] = conf.get('notification-topics')
ctxt['send_notifications_to_logs'] = conf.get('send-notifications-to-logs')
ctxt['rabbit_heartbeat_timeout_threshold'] = conf.get(
'rabbit-heartbeat-timeout-threshold')

if not self.complete:
return {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ ssl = True
{% if rabbit_ssl_ca -%}
ssl_ca_file = {{ rabbit_ssl_ca }}
{% endif -%}
{% if rabbit_heartbeat_timeout_threshold -%}
heartbeat_timeout_threshold = {{ rabbit_heartbeat_timeout_threshold }}
{% endif -%}
12 changes: 12 additions & 0 deletions tests/contrib/openstack/test_os_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,7 @@ def test_amqp_context_with_data(self):
result = amqp()
expected = {
'oslo_messaging_driver': 'messagingv2',
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand All @@ -1309,6 +1310,7 @@ def test_amqp_context_explicit_relation_id(self):
result = amqp()
expected = {
'oslo_messaging_driver': 'messagingv2',
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': 'rabbitalthost1',
'rabbitmq_password': 'flump',
'rabbitmq_user': 'adam',
Expand All @@ -1328,6 +1330,7 @@ def test_amqp_context_with_data_altname(self):
result = amqp()
expected = {
'oslo_messaging_driver': 'messagingv2',
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand All @@ -1347,6 +1350,7 @@ def test_amqp_context_with_data_ssl(self, _open):
result = amqp()
expected = {
'oslo_messaging_driver': 'messagingv2',
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand All @@ -1370,6 +1374,7 @@ def test_amqp_context_with_data_ssl_noca(self):
result = amqp()
expected = {
'oslo_messaging_driver': 'messagingv2',
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand All @@ -1393,6 +1398,7 @@ def test_amqp_context_with_data_clustered(self):
expected = {
'oslo_messaging_driver': 'messagingv2',
'clustered': True,
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': relation_data['vip'],
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand All @@ -1413,6 +1419,7 @@ def test_amqp_context_with_data_active_active(self):
result = amqp()
expected = {
'oslo_messaging_driver': 'messagingv2',
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': 'rabbithost1',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand Down Expand Up @@ -1458,6 +1465,7 @@ def test_amqp_context_with_ipv6(self, format_ipv6_addr):
result = amqp()
expected = {
'oslo_messaging_driver': 'messagingv2',
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': '[2001:db8:1::1]',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand All @@ -1477,6 +1485,7 @@ def test_amqp_context_with_oslo_messaging(self):
amqp = context.AMQPContext()
result = amqp()
expected = {
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand All @@ -1502,6 +1511,7 @@ def test_amqp_context_with_notification_format(self):
result = amqp()
expected = {
'oslo_messaging_driver': 'messagingv2',
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand All @@ -1522,6 +1532,7 @@ def test_amqp_context_with_notification_topics(self):
result = amqp()
expected = {
'oslo_messaging_driver': 'messagingv2',
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand All @@ -1542,6 +1553,7 @@ def test_amqp_context_with_notifications_to_logs(self):
result = amqp()
expected = {
'oslo_messaging_driver': 'messagingv2',
'rabbit_heartbeat_timeout_threshold': None,
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
Expand Down

0 comments on commit c706f49

Please sign in to comment.