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
This commit is contained in:
David Ames 2017-11-08 18:40:12 +00:00
parent 9a0563bf45
commit 7c065062d2
2 changed files with 16 additions and 6 deletions

View File

@ -372,9 +372,10 @@ def pgsql_db_joined():
def update_all_identity_relation_units(check_db_ready=True):
CONFIGS.write_all()
if is_unit_paused_set():
return
CONFIGS.write_all()
configure_https()
if check_db_ready and not is_db_ready():
log('Allowed_units list provided and this unit not present',
level=INFO)

View File

@ -1137,6 +1137,7 @@ class KeystoneRelationTests(CharmTestCase):
self.assertFalse(self.migrate_database.called)
self.assertFalse(update.called)
@patch.object(hooks, 'configure_https')
@patch.object(hooks, 'admin_relation_changed')
@patch.object(hooks, 'identity_credentials_changed')
@patch.object(hooks, 'identity_changed')
@ -1146,7 +1147,8 @@ class KeystoneRelationTests(CharmTestCase):
is_db_initialized,
identity_changed,
identity_credentials_changed,
admin_relation_changed):
admin_relation_changed,
configure_https):
""" Verify all identity relations are updated """
is_db_initialized.return_value = True
self.relation_ids.return_value = ['identity-relation:0']
@ -1168,8 +1170,9 @@ class KeystoneRelationTests(CharmTestCase):
admin_relation_changed.assert_called_with('identity-relation:0')
self.log.assert_has_calls(log_calls, any_order=True)
@patch.object(hooks, 'configure_https')
@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 """
self.is_db_ready.return_value = False
hooks.update_all_identity_relation_units(check_db_ready=True)
@ -1179,9 +1182,11 @@ class KeystoneRelationTests(CharmTestCase):
'unit not present', level='INFO')
self.assertFalse(self.relation_ids.called)
@patch.object(hooks, 'configure_https')
@patch.object(hooks, 'is_db_initialised')
@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 """
is_db_initialized.return_value = False
hooks.update_all_identity_relation_units(check_db_ready=False)
@ -1192,9 +1197,11 @@ class KeystoneRelationTests(CharmTestCase):
level='INFO')
self.assertFalse(self.relation_ids.called)
@patch.object(hooks, 'configure_https')
@patch.object(hooks, 'is_db_initialised')
@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"""
self.is_elected_leader.return_value = True
is_db_initialized.return_value = True
@ -1204,9 +1211,11 @@ class KeystoneRelationTests(CharmTestCase):
# Still updates relations
self.assertTrue(self.relation_ids.called)
@patch.object(hooks, 'configure_https')
@patch.object(hooks, 'is_db_initialised')
@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"""
self.is_elected_leader.return_value = False
is_db_initialized.return_value = True