Block endpoint reg if cluster partially formed

When an existing cluster of the service is scaled out the new unit
will join with keystone before it is fully clustered. In identity
joined hook the charmhelpers function canonical_url is called which
in turn uses another charmhelpers function, resolve_address.
resolve_address will only return the vip if the vip is set in config
AND the unit is clustered. This means that the units local address
is returned and that is then registered with keystone.

This change gates registering an endpoint if the cluster is
partially formed.

Change-Id: I85e7304b1480a95c784f46490dbcc0c4cc1c3129
Partial-Bug: #1544959
This commit is contained in:
Liam Young 2017-10-03 10:50:02 +00:00
parent c3764d9a8d
commit be3fcbcad3
3 changed files with 14 additions and 0 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ tags
tests/*.img
trusty
.idea
.stestr

View File

@ -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))

View File

@ -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 = []