Skip to content

feat(shell-api): support sh.shardDrainingStatus() and sh.getTransitionToDedicatedConfigServerStatus() MONGOSH-2501#2782

Open
ivandevp wants to merge 2 commits into
mainfrom
MONGOSH-2501-shard-draining-status
Open

feat(shell-api): support sh.shardDrainingStatus() and sh.getTransitionToDedicatedConfigServerStatus() MONGOSH-2501#2782
ivandevp wants to merge 2 commits into
mainfrom
MONGOSH-2501-shard-draining-status

Conversation

@ivandevp

Copy link
Copy Markdown
Collaborator

Server epic SPM-4275 ("RemoveShard Interface Improvements") introduced a decomposed shard-removal workflow on mongod/mongos, including a shardDrainingStatus admin command that reports draining progress for a given shard (or all draining shards if none is specified). A related change, SERVER-110790, exposes the same status information for the config-shard-to-dedicated-config-server transition under its own command name, getTransitionToDedicatedConfigServerStatus, so that the public naming stays conceptually separate from generic shard removal.

This PR surfaces both as sh.* shell helpers:

db.adminCommand({ shardDrainingStatus: "shard1" }) // or shardDrainingStatus: 1 for all shards
db.adminCommand({ getTransitionToDedicatedConfigServerStatus: 1 })

Changes

  • sh.shardDrainingStatus(shardId?) — returns the draining status of the given shard, or of all currently draining shards if no shardId is passed. Gated to server versions >= 8.2.0 (first release containing SERVER-107016/SERVER-106558).
  • sh.getTransitionToDedicatedConfigServerStatus() — takes no arguments, returns the config shard's draining status. Gated to server versions >= 8.3.0 (first release containing SERVER-110790).
  • Both call getConfigDB() first (to confirm the client is connected to mongos, matching the existing isBalancerRunning/isConfigShardEnabled pattern) and use _runAdminReadCommand since these are read-only status queries.
  • Added en_US i18n help text and examples for both new attributes.
  • Added unit tests covering the with/without-shardId cases, result pass-through, error pass-through, and the not-connected-to-mongos warning.

Notes

@ivandevp
ivandevp requested a review from a team as a code owner July 22, 2026 15:58
@ivandevp
ivandevp requested a review from dudaschar July 22, 2026 15:58
Comment on lines +2250 to +2261
shardDrainingStatus: {
link: 'https://mongodb.com/docs/manual/reference/method/sh.shardDrainingStatus',
description:
'Returns the draining status of the given shard, or of all draining shards if no shard is specified. Uses the shardDrainingStatus admin command.',
example: 'sh.shardDrainingStatus(shardId?)',
},
getTransitionToDedicatedConfigServerStatus: {
link: 'https://mongodb.com/docs/manual/reference/method/sh.getTransitionToDedicatedConfigServerStatus',
description:
'Returns the draining status of the config shard while transitioning to a dedicated config server. Uses the getTransitionToDedicatedConfigServerStatus admin command.',
example: 'sh.getTransitionToDedicatedConfigServerStatus()',
},

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These changes will require docs update as they do not exist today.

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.

1 participant