Only toggle the cluster relation on a successful join_cluster and use a unique setting.
This commit is contained in:
commit
68e0417294
|
@ -29,6 +29,7 @@ from charmhelpers.core.hookenv import (
|
|||
status_set,
|
||||
cached,
|
||||
unit_get,
|
||||
relation_set,
|
||||
)
|
||||
|
||||
from charmhelpers.core.host import (
|
||||
|
@ -368,6 +369,9 @@ def cluster_with():
|
|||
time.sleep(random.random() * 100)
|
||||
try:
|
||||
join_cluster(node)
|
||||
# NOTE: toggle the cluster relation to ensure that any peers
|
||||
# already clustered re-assess status correctly
|
||||
relation_set(clustered=get_local_nodename())
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
status_set('blocked', 'Failed to cluster with %s. Exception: %s'
|
||||
|
|
|
@ -367,9 +367,6 @@ def cluster_changed():
|
|||
rabbit.cluster_with()
|
||||
update_nrpe_checks()
|
||||
|
||||
# NOTE: toggle the cluster relation to ensure that any peers already
|
||||
# clustered re-assess status correctly
|
||||
relation_set(clustered=True)
|
||||
# If cluster has changed peer db may have changed so run amqp_changed
|
||||
# to sync any changes
|
||||
for rid in relation_ids('amqp'):
|
||||
|
|
|
@ -173,6 +173,8 @@ class UtilsTests(unittest.TestCase):
|
|||
self.assertEqual(rabbit_utils.leader_node(),
|
||||
'rabbit@juju-devel3-machine-15')
|
||||
|
||||
@mock.patch('rabbit_utils.relation_set')
|
||||
@mock.patch('rabbit_utils.get_local_nodename')
|
||||
@mock.patch('rabbit_utils.wait_app')
|
||||
@mock.patch('rabbit_utils.subprocess.check_call')
|
||||
@mock.patch('rabbit_utils.subprocess.check_output')
|
||||
|
@ -185,7 +187,8 @@ class UtilsTests(unittest.TestCase):
|
|||
mock_clustered, mock_leader_node,
|
||||
mock_running_nodes, mock_time,
|
||||
mock_check_output, mock_check_call,
|
||||
mock_wait_app):
|
||||
mock_wait_app, mock_get_local_nodename,
|
||||
mock_relation_set):
|
||||
mock_cmp_pkgrevno.return_value = True
|
||||
mock_clustered.return_value = False
|
||||
mock_leader_node.return_value = 'rabbit@juju-devel7-machine-11'
|
||||
|
|
Loading…
Reference in New Issue