summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorMarcos Jose Grillo Ramirez <marcos.grillo@mongodb.com>2022-03-18 10:51:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-18 11:43:05 +0000
commitb1dc7f546a006efa5edf063286e4368ca603fe48 (patch)
tree43624a20b5d81f23a1936bec88a91ce388992dd8 /src/mongo/db
parentebb1f3900176b9df1f3c20646f349c9785914c43 (diff)
downloadmongo-b1dc7f546a006efa5edf063286e4368ca603fe48.tar.gz
SERVER-62265 Add setClusterParameter command to mongos
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/auth/action_type.idl1
-rw-r--r--src/mongo/db/auth/builtin_roles.cpp3
-rw-r--r--src/mongo/db/commands/SConscript1
-rw-r--r--src/mongo/db/commands/set_cluster_parameter_command.cpp84
4 files changed, 88 insertions, 1 deletions
diff --git a/src/mongo/db/auth/action_type.idl b/src/mongo/db/auth/action_type.idl
index 42d850d880b..dc11b26fb4a 100644
--- a/src/mongo/db/auth/action_type.idl
+++ b/src/mongo/db/auth/action_type.idl
@@ -161,6 +161,7 @@ enums:
serverStatus : "serverStatus"
setAuthenticationRestriction : "setAuthenticationRestriction"
setChangeStreamOptions: "setChangeStreamOptions"
+ setClusterParameter: "setClusterParameter"
setDefaultRWConcern : "setDefaultRWConcern"
setFeatureCompatibilityVersion : "setFeatureCompatibilityVersion"
setFreeMonitoring : "setFreeMonitoring"
diff --git a/src/mongo/db/auth/builtin_roles.cpp b/src/mongo/db/auth/builtin_roles.cpp
index d4dd9ce743b..cbad7142669 100644
--- a/src/mongo/db/auth/builtin_roles.cpp
+++ b/src/mongo/db/auth/builtin_roles.cpp
@@ -254,7 +254,8 @@ MONGO_INITIALIZER(AuthorizationBuiltinRoles)(InitializerContext* context) {
<< ActionType::setFeatureCompatibilityVersion
<< ActionType::setFreeMonitoring
<< ActionType::setChangeStreamOptions
- << ActionType::getChangeStreamOptions;
+ << ActionType::getChangeStreamOptions
+ << ActionType::setClusterParameter;
clusterManagerRoleDatabaseActions
<< ActionType::clearJumboFlag
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index aca30381f2b..3c6fee64ed5 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -552,6 +552,7 @@ env.Library(
"resize_oplog.cpp",
"resize_oplog.idl",
'rwc_defaults_commands.cpp',
+ 'set_cluster_parameter_command.cpp',
"set_feature_compatibility_version_command.cpp",
"set_index_commit_quorum_command.cpp",
"shutdown_d.cpp",
diff --git a/src/mongo/db/commands/set_cluster_parameter_command.cpp b/src/mongo/db/commands/set_cluster_parameter_command.cpp
new file mode 100644
index 00000000000..0abcb976955
--- /dev/null
+++ b/src/mongo/db/commands/set_cluster_parameter_command.cpp
@@ -0,0 +1,84 @@
+/**
+ * Copyright (C) 2022-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_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kCommand
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/auth/authorization_session.h"
+#include "mongo/db/commands.h"
+#include "mongo/db/commands/set_cluster_parameter_gen.h"
+#include "mongo/logv2/log.h"
+
+namespace mongo {
+
+namespace {
+
+class SetClusterParameterCommand final : public TypedCommand<SetClusterParameterCommand> {
+public:
+ using Request = SetClusterParameter;
+
+ AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
+ return AllowedOnSecondary::kNever;
+ }
+
+ bool adminOnly() const override {
+ return true;
+ }
+
+ std::string help() const override {
+ return "Set cluster parameter on replica set or node";
+ }
+
+ class Invocation final : public InvocationBase {
+ public:
+ using InvocationBase::InvocationBase;
+
+ void typedRun(OperationContext*) {
+ LOGV2(6226501, "Received setClusterParameter on node");
+ }
+
+ private:
+ bool supportsWriteConcern() const override {
+ return false;
+ }
+ NamespaceString ns() const override {
+ return NamespaceString();
+ }
+ void doCheckAuthorization(OperationContext* opCtx) const override {
+ uassert(ErrorCodes::Unauthorized,
+ "Unauthorized",
+ AuthorizationSession::get(opCtx->getClient())
+ ->isAuthorizedForPrivilege(Privilege{ResourcePattern::forClusterResource(),
+ ActionType::setClusterParameter}));
+ }
+ };
+} setClusterParameterCommand;
+} // namespace
+} // namespace mongo