mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-45270 Revert 'SERVER-25284 Show IPs in rs.status()'
This reverts commit e1e95afbd5
.
This commit is contained in:
parent
62f35e9e7b
commit
e53a88a3fa
@ -57,7 +57,6 @@
|
||||
#include "mongo/util/fail_point.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) {
|
||||
@ -1481,7 +1471,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());
|
||||
@ -1522,7 +1511,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();
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include "mongo/util/assert_util.h"
|
||||
#include "mongo/util/log_global_settings.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.
|
||||
|
Loading…
Reference in New Issue
Block a user