summaryrefslogtreecommitdiff
diff options
-rwxr-xr-xhooks/hooks.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/hooks/hooks.py b/hooks/hooks.py
index 2b1ad7f..254fca3 100755
--- a/hooks/hooks.py
+++ b/hooks/hooks.py
@@ -598,8 +598,8 @@ def remove_replset_from_upstart():
"""
try:
mongodb_init_config = open(default_mongodb_init_config).read()
-
- if re.search(' --replSet', mongodb_init_config,
+
+ if re.search(' --replSet', mongodb_init_config,
re.MULTILINE) is not None:
mongodb_init_config = re.sub(' --replSet .\w+', '',
mongodb_init_config)
@@ -1273,16 +1273,12 @@ def replica_set_relation_broken():
c = Connection('localhost')
r = c.admin.command('isMaster')
+ master_node = r['primary']
+ unit = "%s:%s" % (unit_get('private-address'),
+ config('port'))
- try:
- master_node = r['primary']
- except KeyError:
- pass
-
- if 'master_node' in locals(): # unit is part of replicaset
- unit = "%s:%s" % (unit_get('private-address'), config('port'))
- juju_log('Removing myself via %s' % (master_node), 'DEBUG')
- leave_replset(master_node, unit)
+ juju_log('Removing myself via %s' % (master_node), 'DEBUG')
+ leave_replset(master_node, unit)
juju_log('replica_set_relation_broken-finish')