summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/commands')
-rw-r--r--src/mongo/s/commands/cluster_add_shard_cmd.cpp3
-rw-r--r--src/mongo/s/commands/cluster_drop_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_drop_database_cmd.cpp14
-rw-r--r--src/mongo/s/commands/cluster_enable_sharding_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_map_reduce_agg.cpp2
-rw-r--r--src/mongo/s/commands/cluster_move_primary_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_remove_shard_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_shard_collection_cmd.cpp2
8 files changed, 19 insertions, 12 deletions
diff --git a/src/mongo/s/commands/cluster_add_shard_cmd.cpp b/src/mongo/s/commands/cluster_add_shard_cmd.cpp
index c6d943a6740..11cc10beab7 100644
--- a/src/mongo/s/commands/cluster_add_shard_cmd.cpp
+++ b/src/mongo/s/commands/cluster_add_shard_cmd.cpp
@@ -85,7 +85,8 @@ public:
kPrimaryOnlyReadPreference,
"admin",
CommandHelpers::appendMajorityWriteConcern(
- CommandHelpers::appendPassthroughFields(cmdObj, parsedRequest.toCommandForConfig()),
+ CommandHelpers::appendGenericCommandArgs(cmdObj,
+ parsedRequest.toCommandForConfig()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent);
diff --git a/src/mongo/s/commands/cluster_drop_cmd.cpp b/src/mongo/s/commands/cluster_drop_cmd.cpp
index f727489ccc0..da31d35765a 100644
--- a/src/mongo/s/commands/cluster_drop_cmd.cpp
+++ b/src/mongo/s/commands/cluster_drop_cmd.cpp
@@ -98,7 +98,7 @@ public:
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
"admin",
CommandHelpers::appendMajorityWriteConcern(
- CommandHelpers::appendPassthroughFields(
+ CommandHelpers::appendGenericCommandArgs(
cmdObj, BSON("_configsvrDropCollection" << nss.toString())),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent));
diff --git a/src/mongo/s/commands/cluster_drop_database_cmd.cpp b/src/mongo/s/commands/cluster_drop_database_cmd.cpp
index a78cb00fd79..f96a2cef9fc 100644
--- a/src/mongo/s/commands/cluster_drop_database_cmd.cpp
+++ b/src/mongo/s/commands/cluster_drop_database_cmd.cpp
@@ -33,6 +33,7 @@
#include "mongo/base/status.h"
#include "mongo/db/commands.h"
+#include "mongo/db/drop_database_gen.h"
#include "mongo/db/operation_context.h"
#include "mongo/s/catalog_cache.h"
#include "mongo/s/client/shard_registry.h"
@@ -82,9 +83,10 @@ public:
"Cannot drop the admin database",
dbname != NamespaceString::kAdminDb);
+ auto request = DropDatabase::parse(IDLParserErrorContext("dropDatabase"), cmdObj);
uassert(ErrorCodes::BadValue,
"have to pass 1 as db parameter",
- cmdObj.firstElement().isNumber() && cmdObj.firstElement().number() == 1);
+ request.getCommandParameter() == 1);
// Invalidate the database metadata so the next access kicks off a full reload, even if
// sending the command to the config server fails due to e.g. a NetworkError.
@@ -97,12 +99,16 @@ public:
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
"admin",
CommandHelpers::appendMajorityWriteConcern(
- CommandHelpers::appendPassthroughFields(cmdObj,
- BSON("_configsvrDropDatabase" << dbname)),
+ CommandHelpers::appendGenericCommandArgs(cmdObj,
+ BSON("_configsvrDropDatabase" << dbname)),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent));
- CommandHelpers::filterCommandReplyForPassthrough(cmdResponse.response, &result);
+ // The cmdResponse status can be OK even if the config server replied ok: 0.
+ uassertStatusOK(cmdResponse.commandStatus);
+ auto reply = DropDatabaseReply::parse(IDLParserErrorContext("dropDatabase-reply"),
+ cmdResponse.response);
+ CommandHelpers::appendGenericReplyFields(cmdResponse.response, reply.toBSON(), &result);
return true;
}
diff --git a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp
index 4ae07e0264c..9feea9a8a8e 100644
--- a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp
+++ b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp
@@ -113,7 +113,7 @@ public:
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
"admin",
CommandHelpers::appendMajorityWriteConcern(
- CommandHelpers::appendPassthroughFields(cmdObj, remoteCmdObj.obj()),
+ CommandHelpers::appendGenericCommandArgs(cmdObj, remoteCmdObj.obj()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent));
diff --git a/src/mongo/s/commands/cluster_map_reduce_agg.cpp b/src/mongo/s/commands/cluster_map_reduce_agg.cpp
index 58ac2b0129e..3f23738d141 100644
--- a/src/mongo/s/commands/cluster_map_reduce_agg.cpp
+++ b/src/mongo/s/commands/cluster_map_reduce_agg.cpp
@@ -132,7 +132,7 @@ Document serializeToCommand(BSONObj originalCmd, const MapReduce& parsedMr, Pipe
}
// Append generic command options.
- for (const auto& elem : CommandHelpers::appendPassthroughFields(originalCmd, BSONObj())) {
+ for (const auto& elem : CommandHelpers::appendGenericCommandArgs(originalCmd, BSONObj())) {
translatedCmd[elem.fieldNameStringData()] = Value(elem);
}
return translatedCmd.freeze();
diff --git a/src/mongo/s/commands/cluster_move_primary_cmd.cpp b/src/mongo/s/commands/cluster_move_primary_cmd.cpp
index 35919c5c348..596fc0282ad 100644
--- a/src/mongo/s/commands/cluster_move_primary_cmd.cpp
+++ b/src/mongo/s/commands/cluster_move_primary_cmd.cpp
@@ -116,7 +116,7 @@ public:
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
"admin",
CommandHelpers::appendMajorityWriteConcern(
- CommandHelpers::appendPassthroughFields(cmdObj, configMovePrimaryRequest.toBSON()),
+ CommandHelpers::appendGenericCommandArgs(cmdObj, configMovePrimaryRequest.toBSON()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent));
diff --git a/src/mongo/s/commands/cluster_remove_shard_cmd.cpp b/src/mongo/s/commands/cluster_remove_shard_cmd.cpp
index 0e2472be0c2..1690c48b79c 100644
--- a/src/mongo/s/commands/cluster_remove_shard_cmd.cpp
+++ b/src/mongo/s/commands/cluster_remove_shard_cmd.cpp
@@ -85,8 +85,8 @@ public:
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
"admin",
CommandHelpers::appendMajorityWriteConcern(
- CommandHelpers::appendPassthroughFields(cmdObj,
- BSON("_configsvrRemoveShard" << target)),
+ CommandHelpers::appendGenericCommandArgs(cmdObj,
+ BSON("_configsvrRemoveShard" << target)),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponseStatus.commandStatus);
diff --git a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
index d4c4d7901ad..3c95e9ba0d3 100644
--- a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
+++ b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
@@ -115,7 +115,7 @@ public:
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
"admin",
CommandHelpers::appendMajorityWriteConcern(
- CommandHelpers::appendPassthroughFields(cmdObj, configShardCollRequest.toBSON()),
+ CommandHelpers::appendGenericCommandArgs(cmdObj, configShardCollRequest.toBSON()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent));