summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2017-12-08 17:42:14 -0500
committerSara Golemon <sara.golemon@mongodb.com>2017-12-18 16:25:26 -0500
commit1197bbad52d34a2c504f3269373946eed4a557dc (patch)
tree71b0b2e5e7c5b88fd13d829cf702ade6d80cfdb5 /src/mongo/s
parent349dc90077147bb41953b92b132fb2763930834a (diff)
downloadmongo-1197bbad52d34a2c504f3269373946eed4a557dc.tar.gz
SERVER-32277 Remove MONGODB-CR -> SCRAM-SHA-1 upgrade
Diffstat (limited to 'src/mongo/s')
-rw-r--r--src/mongo/s/commands/cluster_user_management_commands.cpp115
1 files changed, 0 insertions, 115 deletions
diff --git a/src/mongo/s/commands/cluster_user_management_commands.cpp b/src/mongo/s/commands/cluster_user_management_commands.cpp
index 323b51c9403..d82af362143 100644
--- a/src/mongo/s/commands/cluster_user_management_commands.cpp
+++ b/src/mongo/s/commands/cluster_user_management_commands.cpp
@@ -796,120 +796,5 @@ public:
} cmdMergeAuthzCollections;
-/**
- * Runs the authSchemaUpgrade on all shards, with the given maxSteps. Upgrades each shard serially,
- * and stops on first failure.
- *
- * Returned error indicates a failure.
- */
-Status runUpgradeOnAllShards(OperationContext* opCtx, int maxSteps, BSONObjBuilder& result) {
- BSONObjBuilder cmdObjBuilder;
- cmdObjBuilder.append("authSchemaUpgrade", 1);
- cmdObjBuilder.append("maxSteps", maxSteps);
- cmdObjBuilder.append("writeConcern", kMajorityWriteConcern.toBSON());
-
- const BSONObj cmdObj = cmdObjBuilder.done();
-
- // Upgrade each shard in turn, stopping on first failure.
- auto shardRegistry = Grid::get(opCtx)->shardRegistry();
- shardRegistry->reload(opCtx);
- vector<ShardId> shardIds;
- shardRegistry->getAllShardIds(&shardIds);
-
- bool hasWCError = false;
- for (const auto& shardId : shardIds) {
- auto shardStatus = shardRegistry->getShard(opCtx, shardId);
- if (!shardStatus.isOK()) {
- return shardStatus.getStatus();
- }
- auto cmdResult = shardStatus.getValue()->runCommandWithFixedRetryAttempts(
- opCtx,
- ReadPreferenceSetting{ReadPreference::PrimaryOnly},
- "admin",
- cmdObj,
- Shard::RetryPolicy::kIdempotent);
- auto status = cmdResult.isOK() ? std::move(cmdResult.getValue().commandStatus)
- : std::move(cmdResult.getStatus());
- if (!status.isOK()) {
- return Status(status.code(),
- str::stream() << "Failed to run authSchemaUpgrade on shard " << shardId
- << causedBy(cmdResult.getStatus()));
- }
-
- // If the result has a writeConcernError, append it.
- if (!hasWCError) {
- if (auto wcErrorElem = cmdResult.getValue().response["writeConcernError"]) {
- appendWriteConcernErrorToCmdResponse(shardId, wcErrorElem, result);
- hasWCError = true;
- }
- }
- }
-
- return Status::OK();
-}
-
-class CmdAuthSchemaUpgrade : public BasicCommand {
-public:
- CmdAuthSchemaUpgrade() : BasicCommand("authSchemaUpgrade") {}
-
- virtual bool slaveOk() const {
- return false;
- }
-
- virtual bool adminOnly() const {
- return true;
- }
-
- bool supportsWriteConcern(const BSONObj& cmd) const override {
- return true;
- }
-
- virtual void help(stringstream& ss) const {
- ss << "Upgrades the auth data storage schema";
- }
-
- virtual Status checkAuthForCommand(Client* client,
- const std::string& dbname,
- const BSONObj& cmdObj) {
- return auth::checkAuthForAuthSchemaUpgradeCommand(client);
- }
-
- bool run(OperationContext* opCtx,
- const string& dbname,
- const BSONObj& cmdObj,
- BSONObjBuilder& result) {
- // Run the authSchemaUpgrade command on the config servers
- if (!Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand(
- opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result)) {
- return false;
- }
-
- auth::AuthSchemaUpgradeArgs parsedArgs;
- Status status = auth::parseAuthSchemaUpgradeCommand(cmdObj, dbname, &parsedArgs);
- if (!status.isOK()) {
- return appendCommandStatus(result, status);
- }
-
- // Optionally run the authSchemaUpgrade command on the individual shards
- if (parsedArgs.shouldUpgradeShards) {
- status = runUpgradeOnAllShards(opCtx, parsedArgs.maxSteps, result);
- if (!status.isOK()) {
- // If the status is a write concern error, append a writeConcernError instead of
- // and error message.
- if (ErrorCodes::isWriteConcernError(status.code())) {
- WriteConcernErrorDetail wcError;
- wcError.setErrMessage(status.reason());
- wcError.setErrCode(status.code());
- result.append("writeConcernError", wcError.toBSON());
- } else {
- return appendCommandStatus(result, status);
- }
- }
- }
- return true;
- }
-
-} cmdAuthSchemaUpgrade;
-
} // namespace
} // namespace mongo