check_replica_set false positives

Bug #1930552 reported by Laurent Sesquès
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MongoDB Charm
Fix Released
Medium
Benjamin Allot

Bug Description

Since https://code.launchpad.net/~peter-sabaini/charm-mongodb/+git/charm-mongodb/+merge/396580, the charm sets up a check for replica set:

+ name = get_replica_set_name()
[...]
+ mongo_res = get_cmd_result(
+ ["/usr/bin/mongo", name, "--quiet", "--eval", "JSON.stringify(rs.status())"]
+ )

This only works if we chose a replicaset value that corresponds to a host on which this mongodb is running.

I think that this check should be replaced with something like:
host, port, replicaset = get_mongo_details()
mongo_res = get_cmd_result(
    ["/usr/bin/mongo", "{}:{}".format(host, port), "--quiet", "--eval", "JSON.stringify(rs.status('{}'.format(replicaset)))"]

Also, the check name should be updated with:
- shortname="check_replica_sets",
+ shortname="replica_sets",
Because the check name is automatically prepended with 'check_', currently leading to:

$ grep check_replica_sets /etc/nagios/nrpe.d/*check_replica_sets*
# check check_replica_sets
command[check_check_replica_sets]=/usr/local/lib/nagios/plugins/check_replica_sets.py

And finalyy of course, the tests should be updated to catch this issue.

Related branches

Edin S (exsdev)
Changed in charm-mongodb:
importance: Undecided → Medium
Changed in charm-mongodb:
status: New → Triaged
Benjamin Allot (ballot)
Changed in charm-mongodb:
assignee: nobody → Benjamin Allot (ballot)
Benjamin Allot (ballot)
Changed in charm-mongodb:
status: Triaged → Fix Committed
Xav Paice (xavpaice)
Changed in charm-mongodb:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.