Merge "Block endpoint reg if cluster partially formed"

This commit is contained in:
Jenkins 2017-10-11 12:41:32 +00:00 committed by Gerrit Code Review
commit 569c9b6cd9
2 changed files with 13 additions and 0 deletions

View File

@ -27,6 +27,7 @@ from charmhelpers.core.hookenv import (
is_relation_made,
local_unit,
log,
DEBUG,
ERROR,
WARNING,
relation_get,
@ -100,6 +101,7 @@ from neutron_api_context import (
from charmhelpers.contrib.hahelpers.cluster import (
get_hacluster_config,
is_clustered,
is_elected_leader,
)
@ -396,6 +398,10 @@ def relation_broken():
@hooks.hook('identity-service-relation-joined')
def identity_joined(rid=None, relation_trigger=False):
if config('vip') and not is_clustered():
log('Defering registration until clustered', level=DEBUG)
return
public_url = '{}:{}'.format(canonical_url(CONFIGS, PUBLIC),
api_port('neutron-server'))
admin_url = '{}:{}'.format(canonical_url(CONFIGS, ADMIN),

View File

@ -66,6 +66,7 @@ TO_PATCH = [
'get_l2population',
'get_overlay_network_type',
'git_install',
'is_clustered',
'is_elected_leader',
'is_qos_requested_and_valid',
'is_relation_made',
@ -451,6 +452,12 @@ class NeutronAPIHooksTests(CharmTestCase):
relation_settings=_endpoints
)
def test_identity_joined_partial_cluster(self):
self.is_clustered.return_value = False
self.test_config.set('vip', '10.0.0.10')
hooks.identity_joined()
self.assertFalse(self.relation_set.called)
@patch('charmhelpers.contrib.openstack.ip.service_name',
lambda *args: 'neutron-api')
@patch('charmhelpers.contrib.openstack.ip.unit_get')