diff options
author | Timothy Kuhlman <tim@backgroundprocess.com> | 2017-09-12 16:52:05 -0600 |
---|---|---|
committer | Timothy Kuhlman <tim@backgroundprocess.com> | 2017-09-12 16:52:05 -0600 |
commit | 9e0b579ca37befbcae8195be146f12c46dd74af9 (patch) | |
tree | fed82c4e4117dc211f54f6be65ede2f48b22548e | |
parent | 76e5cf5ca11003653e1c03660157e4b10386f81e (diff) | |
parent | 15460cdd57e5888ce42d7d972848a6b0220e7413 (diff) |
[martin-hilton, r=timkuhlman] The stops the replica-set-relation-broken hook from erroring if the unit isn't in a replica set.
-rwxr-xr-x | hooks/hooks.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/hooks/hooks.py b/hooks/hooks.py index aa09ff5..eafce5a 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -1166,6 +1166,12 @@ def replica_set_relation_joined(): juju_log("replica_set_relation_joined-finish") +def in_replica_set(): + c = Connection('localhost') + r = run_admin_command(c, 'isMaster') + return 'setName' in r + + def am_i_primary(): c = Connection('localhost') for i in xrange(10): @@ -1260,6 +1266,11 @@ def replica_set_relation_departed(): def replica_set_relation_broken(): juju_log('replica_set_relation_broken-start') + if not in_replica_set(): + juju_log('not in replica set', level=DEBUG) + juju_log('replica_set_relation_broken-finish') + return + if am_i_primary(): juju_log('I was primary - removing myself via new primary.', 'DEBUG') mongo_client('localhost', 'rs.stepDown()') |