From 1f5a09b55ebfed7f3a0597316cffb04f512dc443 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Fri, 10 May 2019 09:12:36 +0000 Subject: [PATCH] Check Apache ssl dir when determining restart map If the certificates that Apache is using change then Apache needs to be restarted. This change adds the SSL directory to the restart map to ensure any certificate changes trigger a restart. Change-Id: I1fd46865350e6a9cb35f4209fcf8dd201e6f1441 Closes-Bug: 1828530 --- hooks/keystone_utils.py | 9 ++++++--- unit_tests/test_keystone_utils.py | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/hooks/keystone_utils.py b/hooks/keystone_utils.py index b37a85e4..24c5eb78 100644 --- a/hooks/keystone_utils.py +++ b/hooks/keystone_utils.py @@ -626,9 +626,12 @@ def register_configs(): def restart_map(): - return OrderedDict([(cfg, v['services']) - for cfg, v in resource_map().items() - if v['services']]) + restart_map = OrderedDict([(cfg, v['services']) + for cfg, v in resource_map().items() + if v['services']]) + if os.path.isdir(APACHE_SSL_DIR): + restart_map['{}/*'.format(APACHE_SSL_DIR)] = ['apache2'] + return restart_map def services(): diff --git a/unit_tests/test_keystone_utils.py b/unit_tests/test_keystone_utils.py index 01bd7dce..33eba9a6 100644 --- a/unit_tests/test_keystone_utils.py +++ b/unit_tests/test_keystone_utils.py @@ -1511,3 +1511,23 @@ class TestKeystoneUtils(CharmTestCase): 'cluster': {'interface': 'openstack-ha'}}} metadata.return_value = _metadata self.assertEqual(utils.container_scoped_relations(), ['ha']) + + @patch.object(utils, 'resource_map') + @patch.object(utils.os.path, 'isdir') + def test_restart_map(self, osp_isdir, resource_map): + rsc_map = collections.OrderedDict([ + ('file1', { + 'services': ['svc1'], + 'contexts': ['ctxt1']})]) + resource_map.return_value = rsc_map + osp_isdir.return_value = False + self.assertEqual( + utils.restart_map(), + collections.OrderedDict([ + ('file1', ['svc1'])])) + osp_isdir.return_value = True + self.assertEqual( + utils.restart_map(), + collections.OrderedDict([ + ('file1', ['svc1']), + ('/etc/apache2/ssl/keystone/*', ['apache2'])]))