From 6c8ec9595894baa6ea0e3b87ad7b43be10906dba Mon Sep 17 00:00:00 2001 From: Tommaso Tocci Date: Tue, 15 Nov 2022 11:19:02 +0000 Subject: SERVER-71299 Fail startup if no ClusterId is found --- src/mongo/s/cluster_identity_loader.cpp | 6 ------ src/mongo/s/cluster_identity_loader_test.cpp | 8 ++++---- 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 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( -- cgit v1.2.1