diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2019-12-27 15:03:22 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-12-27 15:03:22 +0000 |
commit | 271d73eb1b7acfb5ed601c3219a65dcbf06a1f27 (patch) | |
tree | ca949394ccfaae33d663eb6147303215dff576b9 | |
parent | 38e05a18e716da5020d8f01f37e8bd8cf8f769b1 (diff) | |
download | mongo-271d73eb1b7acfb5ed601c3219a65dcbf06a1f27.tar.gz |
Revert 'SERVER-25284 Show IPs in rs.status()'
This reverts commit e1e95afbd58a7449dd1765cb910b4d136f95fcc4.
-rw-r--r-- | src/mongo/db/repl/topology_coordinator.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/repl/topology_coordinator_v1_test.cpp | 43 |
2 files changed, 0 insertions, 55 deletions
diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp index b58f91471b1..8dd4927061b 100644 --- a/src/mongo/db/repl/topology_coordinator.cpp +++ b/src/mongo/db/repl/topology_coordinator.cpp @@ -57,7 +57,6 @@ #include "mongo/util/fail_point_service.h" #include "mongo/util/hex.h" #include "mongo/util/log.h" -#include "mongo/util/net/socket_utils.h" #include "mongo/util/scopeguard.h" #include "mongo/util/str.h" @@ -135,15 +134,6 @@ bool _hasOnlyAuthErrorUpHeartbeats(const std::vector<MemberData>& hbdata, const void appendOpTime(BSONObjBuilder* bob, const char* elemName, const OpTime& opTime) { opTime.append(bob, elemName); } - -void appendIP(BSONObjBuilder* bob, const char* elemName, const HostAndPort& hostAndPort) { - auto ip = hostbyname(hostAndPort.host().c_str()); - if (ip == "") { - bob->appendNull("ip"); - } else { - bob->append("ip", ip); - } -} } // namespace void TopologyCoordinator::PingStats::start(Date_t now) { @@ -1451,7 +1441,6 @@ void TopologyCoordinator::prepareStatusResponse(const ReplSetStatusArgs& rsStatu BSONObjBuilder bb; bb.append("_id", _selfConfig().getId().getData()); bb.append("name", _selfConfig().getHostAndPort().toString()); - appendIP(&bb, "ip", _selfConfig().getHostAndPort()); bb.append("health", 1.0); bb.append("state", static_cast<int>(myState.s)); bb.append("stateStr", myState.toString()); @@ -1494,7 +1483,6 @@ void TopologyCoordinator::prepareStatusResponse(const ReplSetStatusArgs& rsStatu BSONObjBuilder bb; bb.append("_id", itConfig.getId().getData()); bb.append("name", itConfig.getHostAndPort().toString()); - appendIP(&bb, "ip", itConfig.getHostAndPort()); double h = it->getHealth(); bb.append("health", h); const MemberState state = it->getState(); diff --git a/src/mongo/db/repl/topology_coordinator_v1_test.cpp b/src/mongo/db/repl/topology_coordinator_v1_test.cpp index f6483cc3197..e2fdbee5b07 100644 --- a/src/mongo/db/repl/topology_coordinator_v1_test.cpp +++ b/src/mongo/db/repl/topology_coordinator_v1_test.cpp @@ -46,7 +46,6 @@ #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" #include "mongo/util/net/hostandport.h" -#include "mongo/util/net/socket_utils.h" #include "mongo/util/scopeguard.h" #include "mongo/util/time_support.h" @@ -1774,48 +1773,6 @@ TEST_F(TopoCoordTest, ReplSetGetStatusWriteMajorityDifferentFromMajorityVoteCoun ASSERT_EQUALS(2, rsStatus["writeMajorityCount"].numberInt()); } - -TEST_F(TopoCoordTest, ReplSetGetStatusIPs) { - BSONObj initialSyncStatus = BSON("failedInitialSyncAttempts" << 1); - std::string setName = "mySet"; - auto now = Date_t::fromMillisSinceEpoch(100); - auto originalIPv6Enabled = IPv6Enabled(); - ON_BLOCK_EXIT([&] { enableIPv6(originalIPv6Enabled); }); - - auto testIP = [&](const std::string& hostAndIP) -> std::string { - // Test framework requires that time moves forward. - now += Milliseconds(10); - updateConfig(BSON("_id" << setName << "version" << 1 << "members" - << BSON_ARRAY(BSON("_id" << 0 << "host" << hostAndIP))), - 0, - now); - - BSONObjBuilder statusBuilder; - Status resultStatus(ErrorCodes::InternalError, "prepareStatusResponse didn't set result"); - getTopoCoord().prepareStatusResponse({}, &statusBuilder, &resultStatus); - ASSERT_OK(resultStatus); - BSONObj rsStatus = statusBuilder.obj(); - unittest::log() << rsStatus; - auto elem = rsStatus["members"].Array()[0]["ip"]; - return elem.isNull() ? "null" : elem.String(); - }; - - // We can't rely on any hostname like mongodb.org that requires DNS from the CI machine, test - // localhost and IP literals. - enableIPv6(false); - ASSERT_EQUALS("127.0.0.1", testIP("localhost:1234")); - enableIPv6(true); - // localhost can resolve to IPv4 or IPv6 depending on precedence. - auto localhostIP = testIP("localhost:1234"); - if (localhostIP != "127.0.0.1" && localhostIP != "::1") { - FAIL(str::stream() << "Expected localhost IP to be 127.0.0.1 or ::1, not " << localhostIP); - } - - ASSERT_EQUALS("1.2.3.4", testIP("1.2.3.4:1234")); - ASSERT_EQUALS("::1", testIP("[::1]:1234")); - ASSERT_EQUALS("null", testIP("test0:1234")); -} - TEST_F(TopoCoordTest, NodeReturnsInvalidReplicaSetConfigInResponseToGetStatusWhenAbsentFromConfig) { // This test starts by configuring a TopologyCoordinator to NOT be a member of a 3 node // replica set. Then running prepareStatusResponse should fail. |