summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/SConscript9
-rw-r--r--src/mongo/db/repl/repl_set_test_egress.cpp158
-rw-r--r--src/mongo/db/repl/repl_set_test_egress.idl56
-rw-r--r--src/mongo/executor/network_interface.h10
-rw-r--r--src/mongo/executor/network_interface_mock.h2
-rw-r--r--src/mongo/executor/network_interface_tl.cpp12
-rw-r--r--src/mongo/executor/network_interface_tl.h5
7 files changed, 0 insertions, 252 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 8a9313e5fb0..b1aa28819d9 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -828,24 +828,15 @@ env.Library(
source=[
'repl_set_command.cpp',
'repl_set_get_status_cmd.cpp',
- 'repl_set_test_egress.cpp',
- env.Idlc('repl_set_test_egress.idl')[0],
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/auth/auth',
'$BUILD_DIR/mongo/db/auth/authprivilege',
'$BUILD_DIR/mongo/db/commands',
- '$BUILD_DIR/mongo/db/commands/test_commands_enabled',
'$BUILD_DIR/mongo/db/lasterror',
'$BUILD_DIR/mongo/db/repl/repl_coordinator_interface',
],
- LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/executor/connection_pool_executor',
- '$BUILD_DIR/mongo/executor/network_interface',
- '$BUILD_DIR/mongo/executor/network_interface_factory',
- '$BUILD_DIR/mongo/executor/network_interface_tl',
- ],
)
env.Library(
diff --git a/src/mongo/db/repl/repl_set_test_egress.cpp b/src/mongo/db/repl/repl_set_test_egress.cpp
deleted file mode 100644
index d7373da7541..00000000000
--- a/src/mongo/db/repl/repl_set_test_egress.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * Copyright (C) 2020-present MongoDB, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the Server Side Public License, version 1,
- * as published by MongoDB, Inc.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Server Side Public License for more details.
- *
- * You should have received a copy of the Server Side Public License
- * along with this program. If not, see
- * <http://www.mongodb.com/licensing/server-side-public-license>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the Server Side Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork
-
-#include "mongo/db/commands.h"
-#include "mongo/db/commands/test_commands_enabled.h"
-#include "mongo/db/operation_context.h"
-#include "mongo/db/repl/repl_set_test_egress_gen.h"
-#include "mongo/db/repl/replication_coordinator.h"
-#include "mongo/executor/network_interface_factory.h"
-#include "mongo/executor/network_interface_tl.h"
-#include "mongo/logv2/log.h"
-#include "mongo/util/duration.h"
-#include "mongo/util/net/hostandport.h"
-
-namespace mongo {
-namespace repl {
-namespace {
-
-HostAndPort selectTarget(OperationContext* opCtx) {
- auto members = ReplicationCoordinator::get(opCtx)->getMemberData();
-
- for (const auto& member : members) {
- if (member.up() && !member.isSelf()) {
- return member.getHostAndPort();
- }
- }
-
- uasserted(ErrorCodes::InternalError, "No viable replica set members to conenct to");
-}
-
-HostAndPort validateTarget(OperationContext* opCtx, StringData targetStr) {
- auto members = ReplicationCoordinator::get(opCtx)->getMemberData();
-
- auto target = HostAndPort::parseThrowing(targetStr);
- for (const auto& member : members) {
- if (target == member.getHostAndPort()) {
- if (member.isSelf()) {
- LOGV2_WARNING(4697200,
- "Using replSetTestEgress to connect to self",
- "target"_attr = targetStr);
- } else if (!member.up()) {
- LOGV2_WARNING(4697201,
- "replSetTestEgress connecting to node which appears down",
- "target"_attr = targetStr);
- }
-
- return target;
- }
- }
-
- uasserted(ErrorCodes::BadValue, str::stream() << targetStr << " is not a replica set member");
-}
-
-constexpr auto kReplSetTestEgress = "replSetTestEgress"_sd;
-auto getNetworkInterface() {
- static auto uniqueNI = ([] {
- auto ret = executor::makeNetworkInterface(kReplSetTestEgress.toString());
- ret->startup();
- return ret;
- })();
- return uniqueNI.get();
-}
-
-const Status kDisconnectStatus(ErrorCodes::ClientDisconnect, "Invalidating temporary connection");
-class CmdReplSetTestEgress final : public TypedCommand<CmdReplSetTestEgress> {
-public:
- using Request = ReplSetTestEgress;
- using Reply = ReplSetTestEgressReply;
-
- class Invocation final : public InvocationBase {
- public:
- using InvocationBase::InvocationBase;
-
- Reply typedRun(OperationContext* opCtx) {
- const auto& cmd = request();
-
- HostAndPort target;
- if (auto optTarget = cmd.getTarget()) {
- target = validateTarget(opCtx, optTarget.get());
- } else {
- target = selectTarget(opCtx);
- }
- Seconds timeout(cmd.getTimeoutSecs());
-
- // ConnectionPool wants very much to have at least one idle connection
- // at the ready so that we never have to wait for an outgoing request.
- // We must thwart that.
- auto net = getNetworkInterface();
- LOGV2_DEBUG(
- 4697203, 4, "Dropping any existing connections", "target"_attr = target.toString());
- net->dropConnections(target);
- LOGV2_DEBUG(4697204,
- 4,
- "Opening test egress connection",
- "target"_attr = target.toString(),
- "timeout"_attr = timeout);
- net->testEgress(
- target, transport::ConnectSSLMode::kGlobalSSLMode, timeout, kDisconnectStatus);
-
- Reply reply;
- reply.setTarget(target.toString());
- return reply;
- }
-
- private:
- bool supportsWriteConcern() const final {
- return false;
- }
-
- void doCheckAuthorization(OperationContext*) const final {}
-
- NamespaceString ns() const final {
- return NamespaceString(request().getDbName(), "");
- }
- };
-
- bool adminOnly() const final {
- return true;
- }
-
- AllowedOnSecondary secondaryAllowed(ServiceContext*) const final {
- return AllowedOnSecondary::kAlways;
- }
-};
-
-MONGO_REGISTER_TEST_COMMAND(CmdReplSetTestEgress);
-
-} // namespace
-} // namespace repl
-} // namespace mongo
diff --git a/src/mongo/db/repl/repl_set_test_egress.idl b/src/mongo/db/repl/repl_set_test_egress.idl
deleted file mode 100644
index a0ab849ff77..00000000000
--- a/src/mongo/db/repl/repl_set_test_egress.idl
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (C) 2020-present MongoDB, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the Server Side Public License, version 1,
-# as published by MongoDB, Inc.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# Server Side Public License for more details.
-#
-# You should have received a copy of the Server Side Public License
-# along with this program. If not, see
-# <http://www.mongodb.com/licensing/server-side-public-license>.
-#
-# As a special exception, the copyright holders give permission to link the
-# code of portions of this program with the OpenSSL library under certain
-# conditions as described in each individual source file and distribute
-# linked combinations including the program with the OpenSSL library. You
-# must comply with the Server Side Public License in all respects for
-# all of the code used other than as permitted herein. If you modify file(s)
-# with this exception, you may extend this exception to your version of the
-# file(s), but you are not obligated to do so. If you do not wish to do so,
-# delete this exception statement from your version. If you delete this
-# exception statement from all source files in the program, then also delete
-# it in the license file.
-#
-global:
- cpp_namespace: "mongo::repl"
-
-imports:
- - "mongo/idl/basic_types.idl"
-
-structs:
- replSetTestEgressReply:
- description: "Result of attempting to connect to cluster member"
- fields:
- target:
- description: "Actual member connected to"
- type: string
-
-commands:
- replSetTestEgress:
- description: "Attempt to connect to a cluster member"
- namespace: ignored
- fields:
- target:
- description: "Member address to connect and authenticate to, empty to select random member"
- type: string
- optional: true
- timeoutSecs:
- description: "Maximum amount of time to wait for connection (seconds)"
- type: int
- default: 5
- validator:
- gt: 0
diff --git a/src/mongo/executor/network_interface.h b/src/mongo/executor/network_interface.h
index 1a5c35aa594..d269fb2443f 100644
--- a/src/mongo/executor/network_interface.h
+++ b/src/mongo/executor/network_interface.h
@@ -233,16 +233,6 @@ public:
*/
virtual void dropConnections(const HostAndPort& hostAndPort) = 0;
- /**
- * Acquire a connection and subsequently release it.
- * If status is not OK, the connection will be dropped,
- * otherwise the connection will be returned to the pool.
- */
- virtual void testEgress(const HostAndPort& hostAndPort,
- transport::ConnectSSLMode sslMode,
- Milliseconds timeout,
- Status status) = 0;
-
protected:
NetworkInterface();
};
diff --git a/src/mongo/executor/network_interface_mock.h b/src/mongo/executor/network_interface_mock.h
index bb16bd397ec..c67ee4c58a1 100644
--- a/src/mongo/executor/network_interface_mock.h
+++ b/src/mongo/executor/network_interface_mock.h
@@ -139,8 +139,6 @@ public:
void dropConnections(const HostAndPort&) override {}
- void testEgress(const HostAndPort&, transport::ConnectSSLMode, Milliseconds, Status) override {}
-
////////////////////////////////////////////////////////////////////////////////
//
// Methods for simulating network operations and the passage of time.
diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp
index d710caaa802..a988ef76420 100644
--- a/src/mongo/executor/network_interface_tl.cpp
+++ b/src/mongo/executor/network_interface_tl.cpp
@@ -520,18 +520,6 @@ Status NetworkInterfaceTL::startCommand(const TaskExecutor::CallbackHandle& cbHa
return Status::OK();
}
-void NetworkInterfaceTL::testEgress(const HostAndPort& hostAndPort,
- transport::ConnectSSLMode sslMode,
- Milliseconds timeout,
- Status status) {
- auto handle = _pool->get(hostAndPort, sslMode, timeout).get();
- if (status.isOK()) {
- handle->indicateSuccess();
- } else {
- handle->indicateFailure(status);
- }
-}
-
Future<RemoteCommandResponse> NetworkInterfaceTL::CommandState::sendRequest(size_t reqId) {
auto requestState = requestManager->getRequest(reqId);
invariant(requestState);
diff --git a/src/mongo/executor/network_interface_tl.h b/src/mongo/executor/network_interface_tl.h
index 942814473be..34bec18a411 100644
--- a/src/mongo/executor/network_interface_tl.h
+++ b/src/mongo/executor/network_interface_tl.h
@@ -94,11 +94,6 @@ public:
void dropConnections(const HostAndPort& hostAndPort) override;
- void testEgress(const HostAndPort& hostAndPort,
- transport::ConnectSSLMode sslMode,
- Milliseconds timeout,
- Status status) override;
-
private:
struct RequestState;
struct RequestManager;