summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorPavi Vetriselvan <pavithra.vetriselvan@mongodb.com>2020-08-06 09:49:48 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-10 16:44:19 +0000
commit7f4b7630dce4471bfdcdaf0301d8c4bec0d635f8 (patch)
tree7d66cb635a7ac96f8d8d8648cce0080f9e031c34 /src/mongo
parente214f4116559a5beba8f158227c339ebc00f7ea9 (diff)
downloadmongo-7f4b7630dce4471bfdcdaf0301d8c4bec0d635f8.tar.gz
SERVER-49988 Rename response fields if hello command is sent on mongos
(cherry picked from commit 8d495ce686890719e96c66ee6f3d1ddbf7704e78)
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/s/commands/cluster_is_master_cmd.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp
index ed3f8181d4c..490605fbefe 100644
--- a/src/mongo/s/commands/cluster_is_master_cmd.cpp
+++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp
@@ -83,6 +83,12 @@ public:
const BSONObj& cmdObj,
BSONObjBuilder& result) override {
CommandHelpers::handleMarkKillOnClientDisconnect(opCtx);
+
+ // Parse the command name, which should be one of the following: hello, isMaster, or
+ // ismaster. If the command is "hello", we must attach an "isWritablePrimary" response field
+ // instead of "ismaster".
+ bool useLegacyResponseFields = (cmdObj.firstElementFieldNameStringData() != kHelloString);
+
auto& clientMetadataIsMasterState = ClientMetadataIsMasterState::get(opCtx->getClient());
bool seenIsMaster = clientMetadataIsMasterState.hasSeenIsMaster();
if (!seenIsMaster) {
@@ -112,7 +118,11 @@ public:
opCtx->getClient(), std::move(swParseClientMetadata.getValue()));
}
- result.appendBool("ismaster", true);
+ if (useLegacyResponseFields) {
+ result.appendBool("ismaster", true);
+ } else {
+ result.appendBool("isWritablePrimary", true);
+ }
result.append("msg", "isdbgrid");
result.appendNumber("maxBsonObjectSize", BSONObjMaxUserSize);
result.appendNumber("maxMessageSizeBytes", MaxMessageSizeBytes);