diff options
| author | Mario Splivalo <mario.splivalo@canonical.com> | 2017-02-13 15:08:20 +0100 |
|---|---|---|
| committer | Mario Splivalo <mario.splivalo@canonical.com> | 2017-02-13 15:08:20 +0100 |
| commit | b4da771c3704ab0e27baa626e1ab7a9d2975986b (patch) | |
| tree | b10a69cd7e9258a7e3d9ed2ded84a4e8fb9e4864 | |
| parent | 5eb3b4a677395b19ee95b3f47443af02e7908a29 (diff) | |
Reverting last change, this is wrong branch :)
| -rwxr-xr-x | hooks/hooks.py | 18 |
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') |
