[hopem,r=]

Provide min-cluster-size config option to get
round clustering races until we have leadership
election support in Juju.
This commit is contained in:
Edward Hope-Morley 2015-04-17 16:26:42 +01:00
parent ed79d56279
commit cf621bb732
2 changed files with 18 additions and 0 deletions

View File

@ -166,3 +166,9 @@ options:
order for this charm to function correctly, the privacy extension must be
disabled and a non-temporary address must be configured/available on
your network interface.
min-cluster-size:
type: int
default:
description: |
Minimum number of units expected to exist before charm will attempt to
form a cluster.

View File

@ -276,6 +276,18 @@ def cluster_changed():
if rabbit.cluster_with():
# resync nrpe user after clustering
update_nrpe_checks()
min_size = config('min-cluster-size')
if min_size:
size = 0
for rid in relation_ids('cluster'):
size = len(related_units(rid))
if min_size != size:
log("Not enough units to form cluster (required=%s, got=%s)" %
(min_size, size), level=INFO)
return
# If cluster has changed peer db may have changed so run amqp_changed
# to sync any changes
for rid in relation_ids('amqp'):