From 1e4a327a31ff26f426ba3390639b780508ad434a Mon Sep 17 00:00:00 2001 From: Nicolas Bock Date: Thu, 11 Mar 2021 09:35:55 -0700 Subject: [PATCH] Add 'heartbeat_timeout_threshold` option This change adds the `heartbeat_timeout_threshold` option to the `oslo_messaging_rabbit` section. Closes-Bug: #1918673 Signed-off-by: Nicolas Bock --- charmhelpers/contrib/openstack/context.py | 2 ++ .../templates/section-oslo-messaging-rabbit | 3 +++ tests/contrib/openstack/test_os_contexts.py | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/charmhelpers/contrib/openstack/context.py b/charmhelpers/contrib/openstack/context.py index b67dafda8..0780c56d5 100644 --- a/charmhelpers/contrib/openstack/context.py +++ b/charmhelpers/contrib/openstack/context.py @@ -768,6 +768,8 @@ def __call__(self): if send_notifications_to_logs: ctxt['send_notifications_to_logs'] = send_notifications_to_logs + ctxt['rabbit_heartbeat_timeout_threshold'] = conf.get('rabbit-heartbeat-timeout-threshold') + if not self.complete: return {} diff --git a/charmhelpers/contrib/openstack/templates/section-oslo-messaging-rabbit b/charmhelpers/contrib/openstack/templates/section-oslo-messaging-rabbit index bed2216ab..603810ba0 100644 --- a/charmhelpers/contrib/openstack/templates/section-oslo-messaging-rabbit +++ b/charmhelpers/contrib/openstack/templates/section-oslo-messaging-rabbit @@ -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 -%} diff --git a/tests/contrib/openstack/test_os_contexts.py b/tests/contrib/openstack/test_os_contexts.py index 3445d3e64..30b52903e 100644 --- a/tests/contrib/openstack/test_os_contexts.py +++ b/tests/contrib/openstack/test_os_contexts.py @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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',