Skip to content
Snippets Groups Projects
Commit 7c065062 authored by David Ames's avatar David Ames
Browse files

Ensure HTTPS configuration completes

There was a race where the https apache2 site,
openstack_https_frontend.conf, would be rendered in one hook, then
subsequently the config-changed hook would run and enable that site.
However, the subsequent config-changed hook would see the template as
having not changed and therefore it would fail to restart apache2.
This lead to apache2 failing to listen on the correct ports.

This was due to CONFIGS.write_all() being called but a2ensite not
being called. This change fixes this race and adds a call to
configure_https() to ensure the configuration completes and apache2
is restarted.

Change-Id: I229d25c707a0630c9d609fd20a962a0de2e42c77
Closes-Bug: #1723892
parent 9a0563bf
No related branches found
No related tags found
No related merge requests found
...@@ -372,9 +372,10 @@ def pgsql_db_joined(): ...@@ -372,9 +372,10 @@ def pgsql_db_joined():
def update_all_identity_relation_units(check_db_ready=True): def update_all_identity_relation_units(check_db_ready=True):
CONFIGS.write_all()
if is_unit_paused_set(): if is_unit_paused_set():
return return
CONFIGS.write_all()
configure_https()
if check_db_ready and not is_db_ready(): if check_db_ready and not is_db_ready():
log('Allowed_units list provided and this unit not present', log('Allowed_units list provided and this unit not present',
level=INFO) level=INFO)
......
...@@ -1137,6 +1137,7 @@ class KeystoneRelationTests(CharmTestCase): ...@@ -1137,6 +1137,7 @@ class KeystoneRelationTests(CharmTestCase):
self.assertFalse(self.migrate_database.called) self.assertFalse(self.migrate_database.called)
self.assertFalse(update.called) self.assertFalse(update.called)
@patch.object(hooks, 'configure_https')
@patch.object(hooks, 'admin_relation_changed') @patch.object(hooks, 'admin_relation_changed')
@patch.object(hooks, 'identity_credentials_changed') @patch.object(hooks, 'identity_credentials_changed')
@patch.object(hooks, 'identity_changed') @patch.object(hooks, 'identity_changed')
...@@ -1146,7 +1147,8 @@ class KeystoneRelationTests(CharmTestCase): ...@@ -1146,7 +1147,8 @@ class KeystoneRelationTests(CharmTestCase):
is_db_initialized, is_db_initialized,
identity_changed, identity_changed,
identity_credentials_changed, identity_credentials_changed,
admin_relation_changed): admin_relation_changed,
configure_https):
""" Verify all identity relations are updated """ """ Verify all identity relations are updated """
is_db_initialized.return_value = True is_db_initialized.return_value = True
self.relation_ids.return_value = ['identity-relation:0'] self.relation_ids.return_value = ['identity-relation:0']
...@@ -1168,8 +1170,9 @@ class KeystoneRelationTests(CharmTestCase): ...@@ -1168,8 +1170,9 @@ class KeystoneRelationTests(CharmTestCase):
admin_relation_changed.assert_called_with('identity-relation:0') admin_relation_changed.assert_called_with('identity-relation:0')
self.log.assert_has_calls(log_calls, any_order=True) self.log.assert_has_calls(log_calls, any_order=True)
@patch.object(hooks, 'configure_https')
@patch.object(hooks, 'CONFIGS') @patch.object(hooks, 'CONFIGS')
def test_update_all_db_not_ready(self, configs): def test_update_all_db_not_ready(self, configs, configure_https):
""" Verify update identity relations when DB is not ready """ """ Verify update identity relations when DB is not ready """
self.is_db_ready.return_value = False self.is_db_ready.return_value = False
hooks.update_all_identity_relation_units(check_db_ready=True) hooks.update_all_identity_relation_units(check_db_ready=True)
...@@ -1179,9 +1182,11 @@ class KeystoneRelationTests(CharmTestCase): ...@@ -1179,9 +1182,11 @@ class KeystoneRelationTests(CharmTestCase):
'unit not present', level='INFO') 'unit not present', level='INFO')
self.assertFalse(self.relation_ids.called) self.assertFalse(self.relation_ids.called)
@patch.object(hooks, 'configure_https')
@patch.object(hooks, 'is_db_initialised') @patch.object(hooks, 'is_db_initialised')
@patch.object(hooks, 'CONFIGS') @patch.object(hooks, 'CONFIGS')
def test_update_all_db_not_initializd(self, configs, is_db_initialized): def test_update_all_db_not_initializd(self, configs, is_db_initialized,
configure_https):
""" Verify update identity relations when DB is not initialized """ """ Verify update identity relations when DB is not initialized """
is_db_initialized.return_value = False is_db_initialized.return_value = False
hooks.update_all_identity_relation_units(check_db_ready=False) hooks.update_all_identity_relation_units(check_db_ready=False)
...@@ -1192,9 +1197,11 @@ class KeystoneRelationTests(CharmTestCase): ...@@ -1192,9 +1197,11 @@ class KeystoneRelationTests(CharmTestCase):
level='INFO') level='INFO')
self.assertFalse(self.relation_ids.called) self.assertFalse(self.relation_ids.called)
@patch.object(hooks, 'configure_https')
@patch.object(hooks, 'is_db_initialised') @patch.object(hooks, 'is_db_initialised')
@patch.object(hooks, 'CONFIGS') @patch.object(hooks, 'CONFIGS')
def test_update_all_leader(self, configs, is_db_initialized): def test_update_all_leader(self, configs, is_db_initialized,
configure_https):
""" Verify update identity relations when the leader""" """ Verify update identity relations when the leader"""
self.is_elected_leader.return_value = True self.is_elected_leader.return_value = True
is_db_initialized.return_value = True is_db_initialized.return_value = True
...@@ -1204,9 +1211,11 @@ class KeystoneRelationTests(CharmTestCase): ...@@ -1204,9 +1211,11 @@ class KeystoneRelationTests(CharmTestCase):
# Still updates relations # Still updates relations
self.assertTrue(self.relation_ids.called) self.assertTrue(self.relation_ids.called)
@patch.object(hooks, 'configure_https')
@patch.object(hooks, 'is_db_initialised') @patch.object(hooks, 'is_db_initialised')
@patch.object(hooks, 'CONFIGS') @patch.object(hooks, 'CONFIGS')
def test_update_all_not_leader(self, configs, is_db_initialized): def test_update_all_not_leader(self, configs, is_db_initialized,
configure_https):
""" Verify update identity relations when not the leader""" """ Verify update identity relations when not the leader"""
self.is_elected_leader.return_value = False self.is_elected_leader.return_value = False
is_db_initialized.return_value = True is_db_initialized.return_value = True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment