Add support for oslo messaging notifications in Keystone charm

This change introduces a new configuration option `enable-oslo-notify`
to the Keystone charm, which allows users to enable `oslo_messaging_notifications`.
This is necessary for services like Fleio that require Keystone to send notifications.

If `enable-oslo-notify` is set to `True`, the following section is added
to the `keystone.conf`:
[oslo_messaging_notifications] driver = messagingv2

By default, `enable-oslo-notify` is set to `False`, keeping the existing behavior
unchanged unless explicitly configured.

Closes-Bug: #2085335
Change-Id: I0b294f0feea3cac25492e6a40fa662c81819f61e
This commit is contained in:
Fabian Fulga
2024-10-22 12:45:54 +03:00
parent 930f5b31f3
commit 9114d5a2cb
4 changed files with 37 additions and 0 deletions

View File

@@ -477,3 +477,11 @@ options:
this option sets True as the default value, which is consistent with the
default value 'WSGISocketRotation On' in Apache. This option should be
used with caution. Please read the Apache doc page for more information.
enable-notifications:
type: boolean
default: False
description: |
Enables `oslo.messaging` notifications in Keystone.
When set to `True`, Keystone will be configured to send notifications
using the `messagingv2` driver. The default value is `False`,
meaning notifications are disabled unless explicitly enabled.

View File

@@ -270,6 +270,8 @@ class KeystoneContext(context.OSContextGenerator):
ctxt['default_authorization_ttl'] = config('default-authorization-ttl')
ctxt['enable_notifications'] = config('enable-notifications')
return ctxt
ALLOWED_SECURITY_COMPLIANCE_SCHEMA = {
@@ -410,6 +412,16 @@ def fernet_enabled():
return True
def notifications_enabled():
"""Helper function for determining whether notifications are enabled.
:returns: True if notifications are enabled.
:rtype: bool
"""
return config('enable-notifications')
class KeystoneFIDServiceProviderContext(context.OSContextGenerator):
interfaces = ['keystone-fid-service-provider']

View File

@@ -130,3 +130,8 @@ admin_project_name = admin
# Bug #1819134
max_request_body_size = 114688
{% if enable_notifications -%}
[oslo_messaging_notifications]
driver = messagingv2
{% endif -%}

View File

@@ -247,6 +247,18 @@ class TestKeystoneContexts(CharmTestCase):
result = context.fernet_enabled()
self.assertTrue(result)
def test_notifications_enabled_yes(self):
self.os_release.return_value = 'rocky'
self.test_config.set('enable-notifications', True)
result = context.notifications_enabled()
self.assertTrue(result)
def test_notifications_enabled_no(self):
self.os_release.return_value = 'rocky'
self.test_config.set('enable-notifications', False)
result = context.notifications_enabled()
self.assertFalse(result)
@patch.object(context, 'relation_ids')
@patch.object(context, 'related_units')
@patch.object(context, 'relation_get')