correctly removing node from cluster
This commit is contained in:
parent
f471c8c334
commit
493e54093f
|
@ -0,0 +1 @@
|
|||
rabbitmq_server_relations.py
|
|
@ -118,10 +118,12 @@ def cluster_with():
|
|||
|
||||
# iterate over all the nodes, join to the first available
|
||||
for node in available_nodes:
|
||||
utils.juju_log('INFO', 'Clustering with remote rabbit host (%s).' % node)
|
||||
utils.juju_log('INFO',
|
||||
'Clustering with remote rabbit host (%s).' % node)
|
||||
for line in out.split('\n'):
|
||||
if re.search(node, line):
|
||||
utils.juju_log('INFO', 'Host already clustered with %s.' % node)
|
||||
utils.juju_log('INFO',
|
||||
'Host already clustered with %s.' % node)
|
||||
return
|
||||
|
||||
try:
|
||||
|
@ -142,6 +144,22 @@ def cluster_with():
|
|||
sys.exit(1)
|
||||
|
||||
|
||||
def break_cluster():
|
||||
try:
|
||||
cmd = [RABBITMQ_CTL, 'stop_app']
|
||||
subprocess.check_call(cmd)
|
||||
cmd = [RABBITMQ_CTL, 'reset']
|
||||
subprocess.check_call(cmd)
|
||||
cmd = [RABBITMQ_CTL, 'start_app']
|
||||
subprocess.check_call(cmd)
|
||||
utils.juju_log('INFO', 'Cluster successfully broken.')
|
||||
return
|
||||
except:
|
||||
# error, no nodes available for clustering
|
||||
utils.juju_log('ERROR', 'Error breaking rabbit cluster')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def set_node_name(name):
|
||||
# update or append RABBITMQ_NODENAME to environment config.
|
||||
# rabbitmq.conf.d is not present on all releases, so use or create
|
||||
|
|
|
@ -157,6 +157,20 @@ def cluster_changed():
|
|||
rabbit.cluster_with()
|
||||
|
||||
|
||||
def cluster_departed():
|
||||
if utils.is_relation_made('ha'):
|
||||
utils.juju_log('INFO',
|
||||
'hacluster relation is present, skipping native '
|
||||
'rabbitmq cluster config.')
|
||||
return
|
||||
l_unit_no = os.getenv('JUJU_UNIT_NAME').split('/')[1]
|
||||
r_unit_no = os.getenv('JUJU_REMOTE_UNIT').split('/')[1]
|
||||
if l_unit_no < r_unit_no:
|
||||
utils.juju_log('INFO', 'cluster_joined: Relation lesser.')
|
||||
return
|
||||
rabbit.break_cluster()
|
||||
|
||||
|
||||
def ha_joined():
|
||||
corosync_bindiface = utils.config_get('ha-bindiface')
|
||||
corosync_mcastport = utils.config_get('ha-mcastport')
|
||||
|
@ -371,6 +385,7 @@ hooks = {
|
|||
'amqp-relation-changed': amqp_changed,
|
||||
'cluster-relation-joined': cluster_joined,
|
||||
'cluster-relation-changed': cluster_changed,
|
||||
'cluster-relation-departed': cluster_departed,
|
||||
'ha-relation-joined': ha_joined,
|
||||
'ha-relation-changed': ha_changed,
|
||||
'ceph-relation-joined': ceph_joined,
|
||||
|
|
Loading…
Reference in New Issue