Sharding Collection Discovery for MongoDB 6.0+ Compatibility and RBAC Stability#185
Open
jaychakra wants to merge 2 commits into
Open
Sharding Collection Discovery for MongoDB 6.0+ Compatibility and RBAC Stability#185jaychakra wants to merge 2 commits into
jaychakra wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR introduces two critical improvements to
getMongoData.js:Feature 1: Fix Sharding Collection Discovery for MongoDB 6.0+
Problem
In MongoDB 6.0+, the
partitionedfield was removed from theconfig.databasescollection. The legacy logic usedif (db.partitioned)to gate collection discovery. Since this field is nowundefined, the script incorrectly skips sharding information for modern clusters, leading to empty reports.Solution
Updated the conditional check to
if (db.partitioned !== false). This remains inclusive ofundefined(modern) andtrue(legacy) while still respecting explicitfalseflags from older versions.Compatibility Matrix
partitionedvaluedb.partitioned !== falsetruetruefalsefalseundefinedtrueFeature 2: Harden Collection Discovery Against Authorization Errors
Problem
When running with restricted RBAC (Role-Based Access Control), the script often encounters "Unauthorized" errors when trying to access internal logs (e.g.,
local.startup_log) or replica set metadata. These errors can cause the script to terminate prematurely or produce noisy, invalid JSON output.Solution
Expanded the collection exclusion list in
printDataInfo. In addition tosystem.*, the script now explicitly skips:replicaset*startup_log*replset*Code Changes Summary
File:
getMongoData.jsVerification
partitionedfield is absent.