summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommaso Tocci <tommaso.tocci@mongodb.com>2022-11-15 11:19:02 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-15 12:15:22 +0000
commit6c8ec9595894baa6ea0e3b87ad7b43be10906dba (patch)
tree4a40b5d2c22704d1445e53703b5d829b0e2ac688
parent0ace76efec4f88f47cae2e35f0a21bd69984f58e (diff)
downloadmongo-6c8ec9595894baa6ea0e3b87ad7b43be10906dba.tar.gz
SERVER-71299 Fail startup if no ClusterId is found
-rw-r--r--src/mongo/s/cluster_identity_loader.cpp6
-rw-r--r--src/mongo/s/cluster_identity_loader_test.cpp8
2 files changed, 4 insertions, 10 deletions
diff --git a/src/mongo/s/cluster_identity_loader.cpp b/src/mongo/s/cluster_identity_loader.cpp
index bb54a644f92..b51d0854b90 100644
--- a/src/mongo/s/cluster_identity_loader.cpp
+++ b/src/mongo/s/cluster_identity_loader.cpp
@@ -100,12 +100,6 @@ StatusWith<OID> ClusterIdentityLoader::_fetchClusterIdFromConfig(
OperationContext* opCtx, const repl::ReadConcernLevel& readConcernLevel) {
auto catalogClient = Grid::get(opCtx)->catalogClient();
auto loadResult = catalogClient->getConfigVersion(opCtx, readConcernLevel);
-
- if (loadResult == ErrorCodes::NoMatchingDocument) {
- // if no version document was found on config server return a zero filled ID
- return OID{};
- }
-
if (!loadResult.isOK()) {
return loadResult.getStatus().withContext("Error loading clusterID");
}
diff --git a/src/mongo/s/cluster_identity_loader_test.cpp b/src/mongo/s/cluster_identity_loader_test.cpp
index d9cbae13151..363bb33ceb3 100644
--- a/src/mongo/s/cluster_identity_loader_test.cpp
+++ b/src/mongo/s/cluster_identity_loader_test.cpp
@@ -123,12 +123,12 @@ TEST_F(ClusterIdentityTest, BasicLoadSuccess) {
}
TEST_F(ClusterIdentityTest, NoConfigVersionDocument) {
- // If no version document is found on config server loadClusterId will return a newly generated
- // clusterId
+ // If no version document is found on config server loadClusterId will return an error
auto future = launchAsync([&] {
- ASSERT_OK(
+ ASSERT_EQ(
ClusterIdentityLoader::get(operationContext())
- ->loadClusterId(operationContext(), repl::ReadConcernLevel::kMajorityReadConcern));
+ ->loadClusterId(operationContext(), repl::ReadConcernLevel::kMajorityReadConcern),
+ ErrorCodes::NoMatchingDocument);
});
expectConfigVersionLoad(