diff options
author | Felipe Reyes <felipe.reyes@canonical.com> | 2018-05-18 21:49:19 +0000 |
---|---|---|
committer | Felipe Reyes <felipe.reyes@canonical.com> | 2018-05-18 21:49:19 +0000 |
commit | 2ef8834546e06c16ed37a71c9abe36dac5d7622a (patch) | |
tree | 9b3a7cc55fbdb870c61e36e75ac3e798aff3b7a8 | |
parent | eca7ebd98976404e20bcefc659a19be5568565b6 (diff) |
Log replSetGetStatus only when status not found for self
-rwxr-xr-x | hooks/hooks.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/hooks/hooks.py b/hooks/hooks.py index 14f06ce..83b19af 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -1214,15 +1214,19 @@ def get_replicaset_status(): c = MongoClient('localhost') try: r = run_admin_command(c, 'replSetGetStatus') - r_pretty = pprint.pformat(r) - juju_log('get_replicaset_status() failed to get replicaset state:' + - r_pretty, 'WARN') for member in r['members']: if 'self' in member: return member['stateStr'] + + # if 'self' was not found in the output, then log a warning and print + # the output given by replSetGetStatus + r_pretty = pprint.pformat(r) + juju_log('get_replicaset_status() failed to get replicaset state:' + + r_pretty, 'WARN') return 'Unknown' except OperationFailure as e: + juju_log('get_replicaset_status() exception: %s' % str(e), DEBUG) if 'not running with --replSet' in str(e): return 'not in replicaset' else: |