diff --git a/.gitignore b/.gitignore index baa63047..9c5e21dc 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ tags tests/*.img trusty .idea +.stestr diff --git a/hooks/glance_relations.py b/hooks/glance_relations.py index e1ce1662..a770b4c7 100755 --- a/hooks/glance_relations.py +++ b/hooks/glance_relations.py @@ -46,6 +46,7 @@ from charmhelpers.core.hookenv import ( config, Hooks, log as juju_log, + DEBUG, ERROR, WARNING, open_port, @@ -72,6 +73,7 @@ from charmhelpers.fetch import ( filter_installed_packages ) from charmhelpers.contrib.hahelpers.cluster import ( + is_clustered, is_elected_leader, get_hacluster_config ) @@ -345,6 +347,10 @@ def ceph_broken(): @hooks.hook('identity-service-relation-joined') def keystone_joined(relation_id=None): + if config('vip') and not is_clustered(): + juju_log('Defering registration until clustered', level=DEBUG) + return + public_url = '{}:9292'.format(canonical_url(CONFIGS, PUBLIC)) internal_url = '{}:9292'.format(canonical_url(CONFIGS, INTERNAL)) admin_url = '{}:9292'.format(canonical_url(CONFIGS, ADMIN)) diff --git a/unit_tests/test_glance_relations.py b/unit_tests/test_glance_relations.py index 1308639d..81952f58 100644 --- a/unit_tests/test_glance_relations.py +++ b/unit_tests/test_glance_relations.py @@ -74,6 +74,7 @@ TO_PATCH = [ 'openstack_upgrade_available', # charmhelpers.contrib.openstack.ha.utils 'update_dns_ha_resource_params', + 'is_clustered', # charmhelpers.contrib.hahelpers.cluster_utils 'is_elected_leader', # hooks.glance_utils @@ -548,6 +549,12 @@ class GlanceRelationTests(CharmTestCase): } self.relation_set.assert_called_with(**ex) + def test_keystone_joined_partial_cluster(self): + self.is_clustered.return_value = False + self.test_config.set('vip', '10.0.0.10') + relations.keystone_joined() + self.assertFalse(self.relation_set.called) + @patch.object(relations, 'CONFIGS') def test_keystone_changes_incomplete(self, configs): configs.complete_contexts.return_value = []