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: Icf2753b6b21347af8106ebad03d81309177d09f2 Partial-Bug: #1544959
This commit is contained in:
parent
d299d38abb
commit
24e3599572
|
@ -34,6 +34,7 @@ from charmhelpers.core.hookenv import (
|
|||
log,
|
||||
status_set,
|
||||
WARNING,
|
||||
DEBUG,
|
||||
)
|
||||
from charmhelpers.core.host import (
|
||||
service_restart,
|
||||
|
@ -84,6 +85,7 @@ from charmhelpers.contrib.network.ip import (
|
|||
)
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
get_hacluster_config,
|
||||
is_clustered,
|
||||
is_elected_leader
|
||||
)
|
||||
from charmhelpers.contrib.peerstorage import (
|
||||
|
@ -350,6 +352,10 @@ def ha_changed():
|
|||
|
||||
@hooks.hook("identity-service-relation-joined")
|
||||
def keystone_joined(relid=None):
|
||||
if config('vip') and not is_clustered():
|
||||
log('Defering registration until clustered', level=DEBUG)
|
||||
return
|
||||
|
||||
public_url = "{}:{}".format(
|
||||
canonical_url(CONFIGS, PUBLIC),
|
||||
CEILOMETER_PORT
|
||||
|
|
|
@ -68,6 +68,7 @@ TO_PATCH = [
|
|||
'mkdir',
|
||||
'init_is_systemd',
|
||||
'get_relation_ip',
|
||||
'is_clustered',
|
||||
]
|
||||
|
||||
|
||||
|
@ -264,6 +265,12 @@ class CeilometerHooksTest(CharmTestCase):
|
|||
requested_roles=hooks.CEILOMETER_ROLE,
|
||||
region='myregion', relation_id=None)
|
||||
|
||||
def test_keystone_joined_partial_cluster(self):
|
||||
self.is_clustered.return_value = False
|
||||
self.test_config.set('vip', '10.0.0.10')
|
||||
hooks.keystone_joined()
|
||||
self.assertFalse(self.relation_set.called)
|
||||
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
def test_ceilometer_joined(self, mock_config):
|
||||
self.relation_ids.return_value = ['ceilometer:0']
|
||||
|
|
Loading…
Reference in New Issue