Skip to content

feat(shell-api): add sh.isConfigShardEnabled and listShards helpers MONGOSH-1919#2400

Merged
nirinchev merged 2 commits intomainfrom
ni/is-config-shard-enabled
Mar 11, 2025
Merged

feat(shell-api): add sh.isConfigShardEnabled and listShards helpers MONGOSH-1919#2400
nirinchev merged 2 commits intomainfrom
ni/is-config-shard-enabled

Conversation

@nirinchev
Copy link
Copy Markdown
Collaborator

@nirinchev nirinchev commented Mar 6, 2025

This adds the sh.isConfigShardEnabled helper for server versions 8.0 and above. It uses listShards and then looks for a shard with _id: 'config'.

Additionally, it adds the sh.listShards helper that calls the listShards admin command.

@nirinchev nirinchev changed the title feat: add sh.isConfigShardEnabled helper feat: add sh.isConfigShardEnabled helper MONGOSH-1919 Mar 6, 2025
@nirinchev nirinchev requested review from addaleax and Copilot March 6, 2025 15:13
@addaleax addaleax changed the title feat: add sh.isConfigShardEnabled helper MONGOSH-1919 feat(shell-api): add sh.isConfigShardEnabled helper MONGOSH-1919 Mar 6, 2025
Copy link
Copy Markdown
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Makes me wonder though, do we also want to expose a generic sh.listShards() helper that forwards to adminCommand({ listShards: 1 })? That feels like something that should be there in some form, no?

@nirinchev
Copy link
Copy Markdown
Collaborator Author

Yeah - was a bit surprised that it wasn't there already, but figured perhaps it was simple enough that nobody requested it 🤷‍♂️ Happy to add it though - seems useful enough to justify having some autocompletion.

@nirinchev nirinchev requested a review from addaleax March 6, 2025 16:59
@nirinchev nirinchev changed the title feat(shell-api): add sh.isConfigShardEnabled helper MONGOSH-1919 feat(shell-api): add sh.isConfigShardEnabled and listShards helpers MONGOSH-1919 Mar 6, 2025
@nirinchev nirinchev requested a review from gagik March 10, 2025 11:31
@nirinchev
Copy link
Copy Markdown
Collaborator Author

ping @addaleax - I know you approved the PR, but I did end up adding a listShards command, so figured it's a "big enough" commit, that you might want to take another look 👀

1
);
expect((await sh.status()).value.shards[0].tags).to.deep.equal([]);
expect((await sh.listShards())[0].tags).to.deep.equal([]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💙

@nirinchev nirinchev merged commit d0132aa into main Mar 11, 2025
135 of 137 checks passed
@nirinchev nirinchev deleted the ni/is-config-shard-enabled branch March 11, 2025 20:34
@nirinchev nirinchev review requested due to automatic review settings March 25, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants