diff options
author | Marcos José Grillo Ramirez <marcos.grillo@mongodb.com> | 2021-07-06 18:59:14 +0200 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-06 17:39:11 +0000 |
commit | c1e968aab0e339d084f1f22b47ce4b2762536b3f (patch) | |
tree | d943fcb80fef6238fd5ff2effe0521f2e5d54bd9 /src | |
parent | d0d4084cffcf71ea6dc56705a413f16051452447 (diff) | |
download | mongo-c1e968aab0e339d084f1f22b47ce4b2762536b3f.tar.gz |
SERVER-27383 Disalow standalone nodes as config server if no queryableBackupMode is specified
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/mongod_options.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index 823cc7b36a5..12e369d5e11 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -603,6 +603,14 @@ Status storeMongodOptions(const moe::Environment& params) { } if (params.count("sharding.clusterRole")) { auto clusterRoleParam = params["sharding.clusterRole"].as<std::string>(); + // Force to set up the node as a replica set, unless we're using queryable backup mode. + if (!params.count("storage.queryableBackupMode") && !params.count("replication.replSet") && + !params.count("replication.replSetName")) { + return Status(ErrorCodes::BadValue, + str::stream() << "Cannot start a " << clusterRoleParam + << " as a standalone server. Please use the option " + "--replset to start the node as a replica set."); + } if (clusterRoleParam == "configsvr") { serverGlobalParams.clusterRole = ClusterRole::ConfigServer; // Config server requires majority read concern. @@ -621,13 +629,6 @@ Status storeMongodOptions(const moe::Environment& params) { storageGlobalParams.dbpath = storageGlobalParams.kDefaultConfigDbPath; } } else if (clusterRoleParam == "shardsvr") { - // Force to set up the node as a replica set, unless we're using queryable backup mode. - if (!params.count("storage.queryableBackupMode") && - !params.count("replication.replSet") && !params.count("replication.replSetName")) { - return Status(ErrorCodes::BadValue, - "Cannot start a shard as a standalone server. Please use the option " - "--replset to start the node as a replica set."); - } serverGlobalParams.clusterRole = ClusterRole::ShardServer; } } |