Fix MongoDB plugin early exit on secondary nodes #850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The plugin was unconditionally exiting when connected to secondary MongoDB nodes, causing no piggybacking data generation and the loss off All MongoDB Services on the Dummy Host.
Fix: Only exit if there is truly no primary node available.
Expected vs Observed Behavior
Expected: Plugin should generate piggybacking data for MongoDB monitoring services even when connected to secondary nodes, as long as a primary exists in the replica set.
Observed: Plugin exits early with unconditional
return
statement when connected to secondary nodes, preventing any piggybacking data generation and causing complete loss of all MongoDB Services on the dummy host.Operating System
Ubuntu 20.04/22.04 LTS (CheckMK agent host)
CheckMK version: 2.4.0p7.cce
Local Setup
Reproduce (routing is managed by Mongo - so its only reproducable if you are being routed to a secondary node)
Root Cause
Line 985 contains
return
without checking if a primary exists in the replica set.Solution
Replace unconditional return with conditional logic that only exits if no primary is available.
Changes
agents/plugins/mk_mongodb.py
Testing
Impact
Fixes MongoDB Atlas monitoring for users with: