summaryrefslogtreecommitdiff
diff options
-rwxr-xr-xhooks/hooks.py10
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: