Do not set client data if not yet clustered

If a unit is not yet clustered then do not send information to
the rabbit clients because the unit is not yet ready for
connections. A fix is also needed on the client side *1 to
gate on recieving data before adding rabbit unit to list
of hosts.

*1 https://github.com/juju/charm-helpers/pull/482

Closes-Bug: #1796886
Change-Id: Ib7554bf22356803feb2637a3db3478be575ba350
This commit is contained in:
Liam Young 2020-06-24 09:13:28 +00:00
parent dec7d941c4
commit 20f865c19f
1 changed files with 7 additions and 0 deletions

View File

@ -347,6 +347,10 @@ def amqp_changed(relation_id=None, remote_unit=None):
peer_store_and_set(relation_id=relation_id,
relation_settings=relation_settings)
elif not is_leader() and rabbit.client_node_is_ready():
if not rabbit.clustered():
log("This node is not clustered yet, defer sending data to client",
level=DEBUG)
return
log("Propagating peer settings to all amqp relations", DEBUG)
# NOTE(jamespage) clear relation to deal with data being
@ -442,6 +446,8 @@ def cluster_changed(relation_id=None, remote_unit=None):
if not is_leader() and is_relation_made('nrpe-external-master'):
update_nrpe_checks()
# Local rabbit maybe clustered now so check and inform clients if needed.
update_clients()
@hooks.hook('stop')
@ -892,6 +898,7 @@ def leader_settings_changed():
# using LE and peerstorage
for rid in relation_ids('cluster'):
relation_set(relation_id=rid, relation_settings={'cookie': cookie})
update_clients()
def pre_install_hooks():