summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Marks <gabriel.marks@mongodb.com>2022-08-30 19:28:35 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-30 21:12:24 +0000
commit36b8246daa269b1a21d63d3f0e11c31b274e6703 (patch)
tree121fc5483e0bdd2effb73d6ac5e913761bb43ba6
parent27f7896edc0828d0c4bae3d70bbec7e8b0a66d98 (diff)
downloadmongo-36b8246daa269b1a21d63d3f0e11c31b274e6703.tar.gz
SERVER-68342 Modify ServerParameter to take tenantId
-rw-r--r--buildscripts/idl/idl/generator.py28
-rw-r--r--docs/server-parameters.md10
-rw-r--r--src/mongo/bson/json.cpp4
-rw-r--r--src/mongo/bson/json.h2
-rw-r--r--src/mongo/client/read_preference.cpp2
-rw-r--r--src/mongo/client/read_preference.h2
-rw-r--r--src/mongo/client/replica_set_monitor_protocol_test_util.cpp4
-rw-r--r--src/mongo/client/replica_set_monitor_server_parameters.cpp10
-rw-r--r--src/mongo/db/auth/authorization_manager_global.cpp10
-rw-r--r--src/mongo/db/auth/authorization_manager_impl.cpp17
-rw-r--r--src/mongo/db/change_stream_options_manager.cpp22
-rw-r--r--src/mongo/db/change_streams_cluster_parameter.cpp3
-rw-r--r--src/mongo/db/change_streams_cluster_parameter.h7
-rw-r--r--src/mongo/db/commands/feature_compatibility_version.cpp10
-rw-r--r--src/mongo/db/commands/get_cluster_parameter_invocation.cpp4
-rw-r--r--src/mongo/db/commands/parameters.cpp59
-rw-r--r--src/mongo/db/commands/set_cluster_parameter_invocation.cpp13
-rw-r--r--src/mongo/db/commands/set_cluster_parameter_invocation.h3
-rw-r--r--src/mongo/db/commands/set_cluster_parameter_invocation_test.cpp19
-rw-r--r--src/mongo/db/free_mon/free_mon_mongod.cpp2
-rw-r--r--src/mongo/db/free_mon/free_mon_mongod.h4
-rw-r--r--src/mongo/db/ftdc/ftdc_mongod.cpp3
-rw-r--r--src/mongo/db/ftdc/ftdc_mongod.h5
-rw-r--r--src/mongo/db/ftdc/ftdc_server.cpp14
-rw-r--r--src/mongo/db/global_settings.cpp15
-rw-r--r--src/mongo/db/initialize_server_global_state.cpp23
-rw-r--r--src/mongo/db/mirror_maestro.cpp13
-rw-r--r--src/mongo/db/process_health/fault_state_machine_test.cpp2
-rw-r--r--src/mongo/db/process_health/health_monitoring_server_parameters.cpp39
-rw-r--r--src/mongo/db/query/ce_mode_parameter.cpp2
-rw-r--r--src/mongo/db/query/ce_mode_parameter.h3
-rw-r--r--src/mongo/db/query/ce_mode_parameter_test.cpp10
-rw-r--r--src/mongo/db/query/framework_control.cpp9
-rw-r--r--src/mongo/db/query/sbe_plan_cache_on_parameter_change.cpp2
-rw-r--r--src/mongo/db/query/sbe_plan_cache_on_parameter_change.h2
-rw-r--r--src/mongo/db/repl/initial_syncer_test.cpp4
-rw-r--r--src/mongo/db/repl/replication_info.cpp2
-rw-r--r--src/mongo/db/s/config/configsvr_set_cluster_parameter_command.cpp8
-rw-r--r--src/mongo/db/s/transaction_coordinator_test_fixture.cpp2
-rw-r--r--src/mongo/db/server_options_helpers.cpp6
-rw-r--r--src/mongo/db/server_options_test.cpp9
-rw-r--r--src/mongo/db/server_parameter.cpp46
-rw-r--r--src/mongo/db/server_parameter.h46
-rw-r--r--src/mongo/db/server_parameter_with_storage.h75
-rw-r--r--src/mongo/db/storage/storage_engine_parameters.cpp10
-rw-r--r--src/mongo/db/storage/storage_options.cpp9
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_parameters.cpp24
-rw-r--r--src/mongo/db/traffic_recorder_validators.cpp2
-rw-r--r--src/mongo/db/traffic_recorder_validators.h4
-rw-r--r--src/mongo/dbtests/framework_options.cpp2
-rw-r--r--src/mongo/idl/cluster_server_parameter_initializer.cpp12
-rw-r--r--src/mongo/idl/cluster_server_parameter_initializer_test.cpp8
-rw-r--r--src/mongo/idl/cluster_server_parameter_op_observer_test.cpp48
-rw-r--r--src/mongo/idl/cluster_server_parameter_refresher.cpp6
-rw-r--r--src/mongo/idl/feature_flag.cpp19
-rw-r--r--src/mongo/idl/feature_flag.h14
-rw-r--r--src/mongo/idl/feature_flag_test.cpp28
-rw-r--r--src/mongo/idl/server_parameter_specialized_test.cpp194
-rw-r--r--src/mongo/idl/server_parameter_test_util.h6
-rw-r--r--src/mongo/idl/server_parameter_with_storage_test.cpp120
-rw-r--r--src/mongo/idl/server_parameter_with_storage_test.h7
-rw-r--r--src/mongo/idl/server_parameter_with_storage_test.idl2
-rw-r--r--src/mongo/logv2/logv2_options.cpp12
-rw-r--r--src/mongo/s/commands/cluster_hello_cmd.cpp2
-rw-r--r--src/mongo/s/hedge_options_util_test.cpp2
-rw-r--r--src/mongo/s/mongos_server_parameters.cpp10
-rw-r--r--src/mongo/s/sharding_task_executor_pool_controller.cpp6
-rw-r--r--src/mongo/s/sharding_task_executor_pool_controller.h5
-rw-r--r--src/mongo/shell/shell_options.cpp2
-rw-r--r--src/mongo/util/fail_point.cpp9
-rw-r--r--src/mongo/util/net/ssl_manager.cpp9
-rw-r--r--src/mongo/util/net/ssl_manager.h5
-rw-r--r--src/mongo/util/net/ssl_parameters.cpp41
-rw-r--r--src/mongo/util/net/ssl_parameters.h6
-rw-r--r--src/mongo/util/net/ssl_parameters_auth.cpp10
-rw-r--r--src/mongo/util/tcmalloc_server_status_section.cpp8
-rw-r--r--src/mongo/util/tcmalloc_set_parameter.cpp56
-rw-r--r--src/mongo/watchdog/watchdog_mongod.cpp2
-rw-r--r--src/mongo/watchdog/watchdog_mongod.h5
79 files changed, 735 insertions, 545 deletions
diff --git a/buildscripts/idl/idl/generator.py b/buildscripts/idl/idl/generator.py
index 0832c3c928a..7636f684494 100644
--- a/buildscripts/idl/idl/generator.py
+++ b/buildscripts/idl/idl/generator.py
@@ -834,21 +834,28 @@ class _CppHeaderFileWriter(_CppFileWriterBase):
self.write_empty_line()
self._writer.write_line(
- 'void append(OperationContext*, BSONObjBuilder&, const std::string&) final;')
+ 'void append(OperationContext*, BSONObjBuilder*, StringData, const boost::optional<TenantId>&) final;'
+ )
if cls.override_set:
- self._writer.write_line('Status set(const BSONElement&) final;')
- self._writer.write_line('Status setFromString(const std::string&) final;')
+ self._writer.write_line(
+ 'Status set(const BSONElement&, const boost::optional<TenantId>&) final;')
+ self._writer.write_line(
+ 'Status setFromString(StringData, const boost::optional<TenantId>&) final;')
# If override_validate is set, provide an override definition. Otherwise, it will inherit
# from the base ServerParameter implementation.
if cls.override_validate:
- self._writer.write_line('Status validate(const BSONElement&) const final;')
+ self._writer.write_line(
+ 'Status validate(const BSONElement&, const boost::optional<TenantId>& tenantId) const final;'
+ )
# The reset() and getClusterParameterTime() methods must be custom implemented for
# specialized cluster server parameters. Provide the declarations here.
if scp.set_at == 'ServerParameterType::kClusterWide':
- self._writer.write_line('Status reset() final;')
- self._writer.write_line('LogicalTime getClusterParameterTime() const final;')
+ self._writer.write_line('Status reset(const boost::optional<TenantId>&) final;')
+ self._writer.write_line(
+ 'LogicalTime getClusterParameterTime(const boost::optional<TenantId>&) const final;'
+ )
if cls.data is not None:
self.write_empty_line()
@@ -2342,15 +2349,16 @@ class _CppSourceFileWriter(_CppFileWriterBase):
if param.redact:
with self._block(
- 'void %s::append(OperationContext*, BSONObjBuilder& b, const std::string& name) {'
+ 'void %s::append(OperationContext*, BSONObjBuilder* b, StringData name, const boost::optional<TenantId>& tenantId) {'
% (cls.name), '}'):
- self._writer.write_line('b << name << "###";')
+ self._writer.write_line('*b << name << "###";')
self.write_empty_line()
# Specialized cluster parameters should also provide the implementation of setFromString().
if is_cluster_param:
- with self._block('Status %s::setFromString(const std::string& str) {' % (cls.name),
- '}'):
+ with self._block(
+ 'Status %s::setFromString(StringData str, const boost::optional<TenantId>& tenantId) {'
+ % (cls.name), '}'):
self._writer.write_line(
'return {ErrorCodes::BadValue, "setFromString should never be used with cluster server parameters"};'
)
diff --git a/docs/server-parameters.md b/docs/server-parameters.md
index 5281ec855ac..3e37f97cdf0 100644
--- a/docs/server-parameters.md
+++ b/docs/server-parameters.md
@@ -129,7 +129,7 @@ to consider the new setting valid. `lt`, `gt`, `lte`, `gte` fields provide for s
or expression maps which evaluate to numeric values. For all other validation cases, specify
callback as a C++ function or static method. Note that validation rules (including callback) may run
in any order. To perform an action after all validation rules have completed, `on_update` should be
-preferred instead. Callback prototype: `Status(const cpp_vartype&);`
+preferred instead. Callback prototype: `Status(const cpp_vartype&, const boost::optional<TenantId>&);`
Any symbols such as global variables or callbacks used by a server parameter must be imported using
the usual IDL machinery via `globals.cpp_includes`. Similarly, all generated code will be nested
@@ -168,7 +168,7 @@ to any other work, this custom constructor must invoke its parent's constructor.
`override_set`: If `true`, the implementer must provide a `set` member function as:
```cpp
-Status {name}::set(const BSONElement& val);
+Status {name}::set(const BSONElement& val, const boost::optional<TenantId>& tenantId);
```
Otherwise the base class implementation `ServerParameter::set` is used. It
invokes `setFromString` using a string representation of `val`, if the `val` is
@@ -176,7 +176,7 @@ holding one of the supported types.
`override_validate`: If `true`, the implementer must provide a `validate` member function as:
```cpp
-Status {name}::validate(const BSONElement& newValueElement);
+Status {name}::validate(const BSONElement& newValueElement, const boost::optional<TenantId>& tenantId);
```
Otherwise, the base class implementation `ServerParameter::validate` is used. This simply returns
`Status::OK()` without performing any kind of validation of the new BSON element.
@@ -186,12 +186,12 @@ injects a placeholder value. If `param.redact` was not specified as `true`, then
must be provided with the following signature:
```cpp
-Status {name}::append(OperationContext*, BSONObjBuidler&, const std::string&);
+Status {name}::append(OperationContext*, BSONObjBuilder*, StringData, const boost::optional<TenantId>& tenantId);
```
Lastly, a `setFromString` method must always be provided with the following signature:
```cpp
-Status {name}::setFromString(const std::string& value);
+Status {name}::setFromString(StringData value, const boost::optional<TenantId>& tenantId);
```
Each server parameter encountered will produce a block of code to run at process startup similar to
diff --git a/src/mongo/bson/json.cpp b/src/mongo/bson/json.cpp
index 1be7c8257ff..5e6e502f8db 100644
--- a/src/mongo/bson/json.cpp
+++ b/src/mongo/bson/json.cpp
@@ -1476,8 +1476,8 @@ BSONObj fromjson(const char* jsonString, int* len) {
return builder.obj();
}
-BSONObj fromjson(const std::string& str) {
- return fromjson(str.c_str());
+BSONObj fromjson(StringData str) {
+ return fromjson(str.toString().c_str());
}
std::string tojson(const BSONObj& obj, JsonStringFormat format, bool pretty) {
diff --git a/src/mongo/bson/json.h b/src/mongo/bson/json.h
index 167654a948a..fee5c115ab3 100644
--- a/src/mongo/bson/json.h
+++ b/src/mongo/bson/json.h
@@ -51,7 +51,7 @@ namespace mongo {
* @throws AssertionException if parsing fails. The message included with
* this assertion includes the character offset where parsing failed.
*/
-BSONObj fromjson(const std::string& str);
+BSONObj fromjson(StringData str);
/** @param len will be size of JSON object in text chars. */
BSONObj fromjson(const char* str, int* len = nullptr);
diff --git a/src/mongo/client/read_preference.cpp b/src/mongo/client/read_preference.cpp
index 5fd56d8b2ce..900375df114 100644
--- a/src/mongo/client/read_preference.cpp
+++ b/src/mongo/client/read_preference.cpp
@@ -65,7 +65,7 @@ TagSet defaultTagSetForMode(ReadPreference mode) {
} // namespace
-Status validateReadPreferenceMode(const std::string& prefStr) {
+Status validateReadPreferenceMode(const std::string& prefStr, const boost::optional<TenantId>&) {
try {
ReadPreference_parse(IDLParserContext(kModeFieldName), prefStr);
} catch (DBException& e) {
diff --git a/src/mongo/client/read_preference.h b/src/mongo/client/read_preference.h
index 837d7391f41..368117d91b5 100644
--- a/src/mongo/client/read_preference.h
+++ b/src/mongo/client/read_preference.h
@@ -46,7 +46,7 @@ using ReadPreference = ReadPreferenceEnum;
/**
* Validate a ReadPreference string. This is intended for use as an IDL validator callback.
*/
-Status validateReadPreferenceMode(const std::string& prefStr);
+Status validateReadPreferenceMode(const std::string& prefStr, const boost::optional<TenantId>&);
/**
* A simple object for representing the list of tags requested by a $readPreference.
diff --git a/src/mongo/client/replica_set_monitor_protocol_test_util.cpp b/src/mongo/client/replica_set_monitor_protocol_test_util.cpp
index 9456e4a8ba9..cb78bbaf097 100644
--- a/src/mongo/client/replica_set_monitor_protocol_test_util.cpp
+++ b/src/mongo/client/replica_set_monitor_protocol_test_util.cpp
@@ -38,14 +38,14 @@ void ReplicaSetMonitorProtocolTestUtil::setRSMProtocol(ReplicaSetMonitorProtocol
BSONElement newParameter = parameterIterator.next();
const auto foundParameter = findRSMProtocolServerParameter();
- uassertStatusOK(foundParameter->second->set(newParameter));
+ uassertStatusOK(foundParameter->second->set(newParameter, boost::none));
}
void ReplicaSetMonitorProtocolTestUtil::resetRSMProtocol() {
const auto defaultParameter = kDefaultParameter[kRSMProtocolFieldName];
const auto foundParameter = findRSMProtocolServerParameter();
- uassertStatusOK(foundParameter->second->set(defaultParameter));
+ uassertStatusOK(foundParameter->second->set(defaultParameter, boost::none));
}
ServerParameter::Map::const_iterator
diff --git a/src/mongo/client/replica_set_monitor_server_parameters.cpp b/src/mongo/client/replica_set_monitor_server_parameters.cpp
index 4d0c1dd4e0e..9b831d768c4 100644
--- a/src/mongo/client/replica_set_monitor_server_parameters.cpp
+++ b/src/mongo/client/replica_set_monitor_server_parameters.cpp
@@ -46,12 +46,14 @@ std::string toString(ReplicaSetMonitorProtocol protocol) {
}
void RSMProtocolServerParameter::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& name) {
- builder.append(name, toString(gReplicaSetMonitorProtocol));
+ BSONObjBuilder* builder,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ builder->append(name, toString(gReplicaSetMonitorProtocol));
}
-Status RSMProtocolServerParameter::setFromString(const std::string& protocolStr) {
+Status RSMProtocolServerParameter::setFromString(StringData protocolStr,
+ const boost::optional<TenantId>&) {
if (protocolStr == toString(ReplicaSetMonitorProtocol::kStreamable)) {
gReplicaSetMonitorProtocol = ReplicaSetMonitorProtocol::kStreamable;
} else if (protocolStr == toString(ReplicaSetMonitorProtocol::kSdam)) {
diff --git a/src/mongo/db/auth/authorization_manager_global.cpp b/src/mongo/db/auth/authorization_manager_global.cpp
index b4655b8970e..2f5e5059a4c 100644
--- a/src/mongo/db/auth/authorization_manager_global.cpp
+++ b/src/mongo/db/auth/authorization_manager_global.cpp
@@ -89,15 +89,17 @@ ServiceContext::ConstructorActionRegisterer createAuthorizationManager(
} // namespace
void AuthzVersionParameter::append(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
int authzVersion;
uassertStatusOK(AuthorizationManager::get(opCtx->getServiceContext())
->getAuthorizationVersion(opCtx, &authzVersion));
- b.append(name, authzVersion);
+ b->append(name, authzVersion);
}
-Status AuthzVersionParameter::setFromString(const std::string& newValueString) {
+Status AuthzVersionParameter::setFromString(StringData newValueString,
+ const boost::optional<TenantId>&) {
return {ErrorCodes::InternalError, "set called on unsettable server parameter"};
}
diff --git a/src/mongo/db/auth/authorization_manager_impl.cpp b/src/mongo/db/auth/authorization_manager_impl.cpp
index cc86cf0fbc5..db1081b8bf3 100644
--- a/src/mongo/db/auth/authorization_manager_impl.cpp
+++ b/src/mongo/db/auth/authorization_manager_impl.cpp
@@ -168,9 +168,9 @@ public:
}
}
- Status setFromString(const std::string& str) {
+ Status setFromString(StringData str) {
std::vector<std::string> strList;
- str::splitStringDelim(str, &strList, ',');
+ str::splitStringDelim(str.toString(), &strList, ',');
std::vector<UserName> out;
for (const auto& nameStr : strList) {
@@ -355,16 +355,19 @@ void handleWaitForUserCacheInvalidation(OperationContext* opCtx, const UserHandl
int authorizationManagerCacheSize;
void AuthorizationManagerPinnedUsersServerParameter::append(OperationContext* opCtx,
- BSONObjBuilder& out,
- const std::string& name) {
- return authorizationManagerPinnedUsers.append(out, name);
+ BSONObjBuilder* out,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ return authorizationManagerPinnedUsers.append(*out, name.toString());
}
-Status AuthorizationManagerPinnedUsersServerParameter::set(const BSONElement& newValue) {
+Status AuthorizationManagerPinnedUsersServerParameter::set(const BSONElement& newValue,
+ const boost::optional<TenantId>&) {
return authorizationManagerPinnedUsers.set(newValue);
}
-Status AuthorizationManagerPinnedUsersServerParameter::setFromString(const std::string& str) {
+Status AuthorizationManagerPinnedUsersServerParameter::setFromString(
+ StringData str, const boost::optional<TenantId>&) {
return authorizationManagerPinnedUsers.setFromString(str);
}
diff --git a/src/mongo/db/change_stream_options_manager.cpp b/src/mongo/db/change_stream_options_manager.cpp
index 816ec7f53da..541b8486621 100644
--- a/src/mongo/db/change_stream_options_manager.cpp
+++ b/src/mongo/db/change_stream_options_manager.cpp
@@ -69,17 +69,19 @@ StatusWith<ChangeStreamOptions> ChangeStreamOptionsManager::setOptions(
}
void ChangeStreamOptionsParameter::append(OperationContext* opCtx,
- BSONObjBuilder& bob,
- const std::string& name) {
+ BSONObjBuilder* bob,
+ StringData name,
+ const boost::optional<TenantId>& tenantId) {
ChangeStreamOptionsManager& changeStreamOptionsManager =
ChangeStreamOptionsManager::get(getGlobalServiceContext());
- bob.append("_id"_sd, name);
- bob.appendElementsUnique(changeStreamOptionsManager.getOptions(opCtx).toBSON());
+ bob->append("_id"_sd, name);
+ bob->appendElementsUnique(changeStreamOptionsManager.getOptions(opCtx).toBSON());
}
-Status ChangeStreamOptionsParameter::set(const BSONElement& newValueElement) {
+Status ChangeStreamOptionsParameter::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId) {
try {
- Status validateStatus = validate(newValueElement);
+ Status validateStatus = validate(newValueElement, tenantId);
if (!validateStatus.isOK()) {
return validateStatus;
}
@@ -97,7 +99,8 @@ Status ChangeStreamOptionsParameter::set(const BSONElement& newValueElement) {
}
}
-Status ChangeStreamOptionsParameter::validate(const BSONElement& newValueElement) const {
+Status ChangeStreamOptionsParameter::validate(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId) const {
try {
BSONObj changeStreamOptionsObj = newValueElement.Obj();
Status validateStatus = Status::OK();
@@ -144,7 +147,7 @@ Status ChangeStreamOptionsParameter::validate(const BSONElement& newValueElement
}
}
-Status ChangeStreamOptionsParameter::reset() {
+Status ChangeStreamOptionsParameter::reset(const boost::optional<TenantId>& tenantId) {
// Replace the current changeStreamOptions with a default-constructed one, which should
// automatically set preAndPostImages.expirationSeconds to 'off' by default.
ChangeStreamOptionsManager& changeStreamOptionsManager =
@@ -154,7 +157,8 @@ Status ChangeStreamOptionsParameter::reset() {
.getStatus();
}
-LogicalTime ChangeStreamOptionsParameter::getClusterParameterTime() const {
+LogicalTime ChangeStreamOptionsParameter::getClusterParameterTime(
+ const boost::optional<TenantId>& tenantId) const {
ChangeStreamOptionsManager& changeStreamOptionsManager =
ChangeStreamOptionsManager::get(getGlobalServiceContext());
return changeStreamOptionsManager.getClusterParameterTime();
diff --git a/src/mongo/db/change_streams_cluster_parameter.cpp b/src/mongo/db/change_streams_cluster_parameter.cpp
index 55df25d1e30..b4c798ccc1c 100644
--- a/src/mongo/db/change_streams_cluster_parameter.cpp
+++ b/src/mongo/db/change_streams_cluster_parameter.cpp
@@ -37,7 +37,8 @@
namespace mongo {
Status validateChangeStreamsClusterParameter(
- const ChangeStreamsClusterParameterStorage& clusterParameter) {
+ const ChangeStreamsClusterParameterStorage& clusterParameter,
+ const boost::optional<TenantId>& tenantId) {
if (clusterParameter.getExpireAfterSeconds() <= 0) {
return Status(ErrorCodes::BadValue,
"Expected a positive integer for 'expireAfterSeconds' field");
diff --git a/src/mongo/db/change_streams_cluster_parameter.h b/src/mongo/db/change_streams_cluster_parameter.h
index ebeedaa0e8b..ee1701a7b87 100644
--- a/src/mongo/db/change_streams_cluster_parameter.h
+++ b/src/mongo/db/change_streams_cluster_parameter.h
@@ -29,7 +29,11 @@
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/base/status.h"
+#include "mongo/db/tenant_id.h"
+
namespace mongo {
class ChangeStreamsClusterParameterStorage;
@@ -38,5 +42,6 @@ class ChangeStreamsClusterParameterStorage;
* Validates 'changeStreams' cluster-wide parameter.
*/
Status validateChangeStreamsClusterParameter(
- const ChangeStreamsClusterParameterStorage& clusterParameter);
+ const ChangeStreamsClusterParameterStorage& clusterParameter,
+ const boost::optional<TenantId>& tenantId);
} // namespace mongo
diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp
index 3b8e8a4654d..dcd25bb23db 100644
--- a/src/mongo/db/commands/feature_compatibility_version.cpp
+++ b/src/mongo/db/commands/feature_compatibility_version.cpp
@@ -545,13 +545,14 @@ void FeatureCompatibilityVersion::clearLastFCVUpdateTimestamp() {
void FeatureCompatibilityVersionParameter::append(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
uassert(ErrorCodes::UnknownFeatureCompatibilityVersion,
str::stream() << name << " is not yet known.",
serverGlobalParams.featureCompatibility.isVersionInitialized());
- BSONObjBuilder featureCompatibilityVersionBuilder(b.subobjStart(name));
+ BSONObjBuilder featureCompatibilityVersionBuilder(b->subobjStart(name));
auto version = serverGlobalParams.featureCompatibility.getVersion();
FeatureCompatibilityVersionDocument fcvDoc = fcvTransitions.getFCVDocument(version);
featureCompatibilityVersionBuilder.appendElements(fcvDoc.toBSON().removeField("_id"));
@@ -582,7 +583,8 @@ void FeatureCompatibilityVersionParameter::append(OperationContext* opCtx,
}
}
-Status FeatureCompatibilityVersionParameter::setFromString(const std::string&) {
+Status FeatureCompatibilityVersionParameter::setFromString(StringData,
+ const boost::optional<TenantId>&) {
return {ErrorCodes::IllegalOperation,
str::stream() << name() << " cannot be set via setParameter. See "
<< feature_compatibility_version_documentation::kCompatibilityLink
diff --git a/src/mongo/db/commands/get_cluster_parameter_invocation.cpp b/src/mongo/db/commands/get_cluster_parameter_invocation.cpp
index fab07f4dca2..0624a103553 100644
--- a/src/mongo/db/commands/get_cluster_parameter_invocation.cpp
+++ b/src/mongo/db/commands/get_cluster_parameter_invocation.cpp
@@ -54,7 +54,7 @@ GetClusterParameterInvocation::retrieveRequestedParameters(OperationContext* opC
// Skip any disabled cluster parameters.
if (requestedParameter->isEnabled()) {
BSONObjBuilder bob;
- requestedParameter->append(opCtx, bob, requestedParameter->name());
+ requestedParameter->append(opCtx, &bob, requestedParameter->name(), boost::none);
parameterValues.push_back(bob.obj().getOwned());
parameterNames.push_back(requestedParameter->name());
}
@@ -182,7 +182,7 @@ GetClusterParameterInvocation::Reply GetClusterParameterInvocation::getDurablePa
for (const auto& defaultParameterName : defaultParameterNames) {
auto defaultParameter = clusterParameters->get(defaultParameterName);
BSONObjBuilder bob;
- defaultParameter->append(opCtx, bob, defaultParameterName);
+ defaultParameter->append(opCtx, &bob, defaultParameterName, boost::none);
retrievedParameters.push_back(bob.obj());
}
}
diff --git a/src/mongo/db/commands/parameters.cpp b/src/mongo/db/commands/parameters.cpp
index 834002ff9b6..997b910de8c 100644
--- a/src/mongo/db/commands/parameters.cpp
+++ b/src/mongo/db/commands/parameters.cpp
@@ -243,14 +243,14 @@ public:
if (all || cmdObj.hasElement(i->first.c_str())) {
if (options.getShowDetails()) {
BSONObjBuilder detailBob(result.subobjStart(i->second->name()));
- i->second->append(opCtx, detailBob, "value");
+ i->second->append(opCtx, &detailBob, "value", boost::none);
detailBob.appendBool("settableAtRuntime",
i->second->allowedToChangeAtRuntime());
detailBob.appendBool("settableAtStartup",
i->second->allowedToChangeAtStartup());
detailBob.doneFast();
} else {
- i->second->append(opCtx, result, i->second->name());
+ i->second->append(opCtx, &result, i->second->name(), boost::none);
}
}
}
@@ -367,7 +367,7 @@ public:
auto oldValueObj = ([&] {
BSONObjBuilder bb;
if (numSet == 0) {
- foundParameter->second->append(opCtx, bb, "was");
+ foundParameter->second->append(opCtx, &bb, "was", boost::none);
}
return bb.obj();
})();
@@ -378,7 +378,7 @@ public:
}
try {
- uassertStatusOK(foundParameter->second->set(parameter));
+ uassertStatusOK(foundParameter->second->set(parameter, boost::none));
} catch (const DBException& ex) {
LOGV2(20496,
"Error setting parameter {parameterName} to {newValue} errMsg: {error}",
@@ -426,16 +426,18 @@ public:
} cmdSet;
void LogLevelServerParameter::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& name) {
- builder.append(name,
- logv2::LogManager::global()
- .getGlobalSettings()
- .getMinimumLogSeverity(mongo::logv2::LogComponent::kDefault)
- .toInt());
+ BSONObjBuilder* builder,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ builder->append(name,
+ logv2::LogManager::global()
+ .getGlobalSettings()
+ .getMinimumLogSeverity(mongo::logv2::LogComponent::kDefault)
+ .toInt());
}
-Status LogLevelServerParameter::set(const BSONElement& newValueElement) {
+Status LogLevelServerParameter::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>&) {
int newValue;
if (!newValueElement.coerce(&newValue) || newValue < 0)
return Status(ErrorCodes::BadValue,
@@ -447,7 +449,8 @@ Status LogLevelServerParameter::set(const BSONElement& newValueElement) {
return Status::OK();
}
-Status LogLevelServerParameter::setFromString(const std::string& strLevel) {
+Status LogLevelServerParameter::setFromString(StringData strLevel,
+ const boost::optional<TenantId>&) {
int newValue;
Status status = NumberParser{}(strLevel, &newValue);
if (!status.isOK())
@@ -463,14 +466,16 @@ Status LogLevelServerParameter::setFromString(const std::string& strLevel) {
}
void LogComponentVerbosityServerParameter::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& name) {
+ BSONObjBuilder* builder,
+ StringData name,
+ const boost::optional<TenantId>&) {
BSONObj currentSettings;
getLogComponentVerbosity(&currentSettings);
- builder.append(name, currentSettings);
+ builder->append(name, currentSettings);
}
-Status LogComponentVerbosityServerParameter::set(const BSONElement& newValueElement) {
+Status LogComponentVerbosityServerParameter::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>&) {
if (!newValueElement.isABSONObj()) {
return Status(ErrorCodes::TypeMismatch,
str::stream()
@@ -479,30 +484,34 @@ Status LogComponentVerbosityServerParameter::set(const BSONElement& newValueElem
return setLogComponentVerbosity(newValueElement.Obj());
}
-Status LogComponentVerbosityServerParameter::setFromString(const std::string& str) try {
+Status LogComponentVerbosityServerParameter::setFromString(StringData str,
+ const boost::optional<TenantId>&) try {
return setLogComponentVerbosity(fromjson(str));
} catch (const DBException& ex) {
return ex.toStatus();
}
void AutomationServiceDescriptorServerParameter::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& name) {
+ BSONObjBuilder* builder,
+ StringData name,
+ const boost::optional<TenantId>&) {
const stdx::lock_guard<Latch> lock(autoServiceDescriptorMutex);
if (!autoServiceDescriptorValue.empty()) {
- builder.append(name, autoServiceDescriptorValue);
+ builder->append(name, autoServiceDescriptorValue);
}
}
-Status AutomationServiceDescriptorServerParameter::set(const BSONElement& newValueElement) {
+Status AutomationServiceDescriptorServerParameter::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>&) {
if (newValueElement.type() != String) {
return {ErrorCodes::TypeMismatch,
"Value for parameter automationServiceDescriptor must be of type 'string'"};
}
- return setFromString(newValueElement.String());
+ return setFromString(newValueElement.String(), boost::none);
}
-Status AutomationServiceDescriptorServerParameter::setFromString(const std::string& str) {
+Status AutomationServiceDescriptorServerParameter::setFromString(StringData str,
+ const boost::optional<TenantId>&) {
auto kMaxSize = 64U;
if (str.size() > kMaxSize)
return {ErrorCodes::Overflow,
@@ -511,7 +520,7 @@ Status AutomationServiceDescriptorServerParameter::setFromString(const std::stri
{
const stdx::lock_guard<Latch> lock(autoServiceDescriptorMutex);
- autoServiceDescriptorValue = str;
+ autoServiceDescriptorValue = str.toString();
}
return Status::OK();
diff --git a/src/mongo/db/commands/set_cluster_parameter_invocation.cpp b/src/mongo/db/commands/set_cluster_parameter_invocation.cpp
index ed85f60fc76..4b04c491894 100644
--- a/src/mongo/db/commands/set_cluster_parameter_invocation.cpp
+++ b/src/mongo/db/commands/set_cluster_parameter_invocation.cpp
@@ -54,11 +54,11 @@ bool SetClusterParameterInvocation::invoke(OperationContext* opCtx,
StringData parameterName = cmdParamObj.firstElement().fieldName();
ServerParameter* serverParameter = _sps->get(parameterName);
- auto [query, update] =
- normalizeParameter(opCtx, cmdParamObj, paramTime, serverParameter, parameterName);
+ auto [query, update] = normalizeParameter(
+ opCtx, cmdParamObj, paramTime, serverParameter, parameterName, cmd.getDbName().tenantId());
BSONObjBuilder oldValueBob;
- serverParameter->append(opCtx, oldValueBob, parameterName.toString());
+ serverParameter->append(opCtx, &oldValueBob, parameterName.toString(), boost::none);
audit::logSetClusterParameter(opCtx->getClient(), oldValueBob.obj(), update);
LOGV2_DEBUG(
@@ -73,7 +73,8 @@ std::pair<BSONObj, BSONObj> SetClusterParameterInvocation::normalizeParameter(
BSONObj cmdParamObj,
const boost::optional<Timestamp>& paramTime,
ServerParameter* sp,
- StringData parameterName) {
+ StringData parameterName,
+ const boost::optional<TenantId>& tenantId) {
BSONElement commandElement = cmdParamObj.firstElement();
uassert(ErrorCodes::IllegalOperation,
"Cluster parameter value must be an object",
@@ -88,7 +89,7 @@ std::pair<BSONObj, BSONObj> SetClusterParameterInvocation::normalizeParameter(
BSONObj query = BSON("_id" << parameterName);
BSONObj update = updateBuilder.obj();
- uassertStatusOK(sp->validate(update));
+ uassertStatusOK(sp->validate(update, tenantId));
return {query, update};
}
@@ -115,7 +116,7 @@ StatusWith<bool> ClusterParameterDBClientService::updateParameterOnDisk(
try {
_dbClient.runCommand(
- NamespaceString::kConfigDb.toString(),
+ NamespaceString::makeClusterParametersNSS(tenantId).dbName().toStringWithTenantId(),
[&] {
write_ops::UpdateCommandRequest updateOp(
NamespaceString::makeClusterParametersNSS(tenantId));
diff --git a/src/mongo/db/commands/set_cluster_parameter_invocation.h b/src/mongo/db/commands/set_cluster_parameter_invocation.h
index f5bf46cb998..c712669a272 100644
--- a/src/mongo/db/commands/set_cluster_parameter_invocation.h
+++ b/src/mongo/db/commands/set_cluster_parameter_invocation.h
@@ -88,7 +88,8 @@ public:
BSONObj cmdParamObj,
const boost::optional<Timestamp>& paramTime,
ServerParameter* sp,
- StringData parameterName);
+ StringData parameterName,
+ const boost::optional<TenantId>& tenantId);
private:
std::unique_ptr<ServerParameterService> _sps;
diff --git a/src/mongo/db/commands/set_cluster_parameter_invocation_test.cpp b/src/mongo/db/commands/set_cluster_parameter_invocation_test.cpp
index 8209b0ee330..3e99e94cf96 100644
--- a/src/mongo/db/commands/set_cluster_parameter_invocation_test.cpp
+++ b/src/mongo/db/commands/set_cluster_parameter_invocation_test.cpp
@@ -70,21 +70,26 @@ public:
: ServerParameter(name, ServerParameterType::kRuntimeOnly) {
this->validateImpl = validateImpl;
}
- void append(OperationContext* opCtx, BSONObjBuilder& b, const std::string& name) {}
+ void append(OperationContext* opCtx,
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {}
void appendSupportingRoundtrip(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {}
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {}
- Status set(const BSONElement& newValueElement) {
+ Status set(const BSONElement& newValueElement, const boost::optional<TenantId>& tenantId) {
return Status(ErrorCodes::BadValue, "Should not call set() in this test");
}
- Status setFromString(const std::string& str) {
- return Status(ErrorCodes::BadValue, "Should not call setFromString in this test");
+ Status setFromString(StringData str, const boost::optional<TenantId>& tenantId) {
+ return Status(ErrorCodes::BadValue, "Should not call setFromString() in this test");
}
- Status validate(const BSONElement& newValueElement) const {
+ Status validate(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId) const {
return validateImpl(newValueElement);
}
diff --git a/src/mongo/db/free_mon/free_mon_mongod.cpp b/src/mongo/db/free_mon/free_mon_mongod.cpp
index 6e1bc93d77d..0d973c16197 100644
--- a/src/mongo/db/free_mon/free_mon_mongod.cpp
+++ b/src/mongo/db/free_mon/free_mon_mongod.cpp
@@ -248,7 +248,7 @@ private:
} // namespace
-Status onValidateFreeMonEndpointURL(StringData str) {
+Status onValidateFreeMonEndpointURL(StringData str, const boost::optional<TenantId>&) {
// Check for http, not https here because testEnabled may not be set yet
if (!str.startsWith("http"_sd) != 0) {
return Status(ErrorCodes::BadValue,
diff --git a/src/mongo/db/free_mon/free_mon_mongod.h b/src/mongo/db/free_mon/free_mon_mongod.h
index 0e0653e6ef7..a17647c4db4 100644
--- a/src/mongo/db/free_mon/free_mon_mongod.h
+++ b/src/mongo/db/free_mon/free_mon_mongod.h
@@ -29,10 +29,12 @@
#pragma once
+#include <boost/optional.hpp>
#include <string>
#include "mongo/db/op_observer/op_observer_registry.h"
#include "mongo/db/service_context.h"
+#include "mongo/db/tenant_id.h"
namespace mongo {
@@ -59,7 +61,7 @@ void notifyFreeMonitoringOnTransitionToPrimary();
*/
void setupFreeMonitoringOpObserver(OpObserverRegistry* registry);
-Status onValidateFreeMonEndpointURL(StringData str);
+Status onValidateFreeMonEndpointURL(StringData str, const boost::optional<TenantId>&);
} // namespace mongo
diff --git a/src/mongo/db/ftdc/ftdc_mongod.cpp b/src/mongo/db/ftdc/ftdc_mongod.cpp
index 49173f12a4d..8da45771f19 100644
--- a/src/mongo/db/ftdc/ftdc_mongod.cpp
+++ b/src/mongo/db/ftdc/ftdc_mongod.cpp
@@ -45,7 +45,8 @@
namespace mongo {
-Status validateCollectionStatsNamespaces(const std::vector<std::string> value) {
+Status validateCollectionStatsNamespaces(const std::vector<std::string> value,
+ const boost::optional<TenantId>& tenantId) {
try {
for (const auto& nsStr : value) {
NamespaceString ns(nsStr);
diff --git a/src/mongo/db/ftdc/ftdc_mongod.h b/src/mongo/db/ftdc/ftdc_mongod.h
index 698fac57f29..9108c39ee57 100644
--- a/src/mongo/db/ftdc/ftdc_mongod.h
+++ b/src/mongo/db/ftdc/ftdc_mongod.h
@@ -29,10 +29,12 @@
#pragma once
+#include <boost/optional.hpp>
#include <string>
#include <vector>
#include "mongo/base/status.h"
+#include "mongo/db/tenant_id.h"
namespace mongo {
@@ -50,6 +52,7 @@ void stopMongoDFTDC();
/**
* Validation callback for setParameter
*/
-Status validateCollectionStatsNamespaces(std::vector<std::string> value);
+Status validateCollectionStatsNamespaces(std::vector<std::string> value,
+ const boost::optional<TenantId>& tenantId);
} // namespace mongo
diff --git a/src/mongo/db/ftdc/ftdc_server.cpp b/src/mongo/db/ftdc/ftdc_server.cpp
index c6f1da3b17c..2c42daf45ef 100644
--- a/src/mongo/db/ftdc/ftdc_server.cpp
+++ b/src/mongo/db/ftdc/ftdc_server.cpp
@@ -73,24 +73,24 @@ synchronized_value<boost::filesystem::path> ftdcDirectoryPathParameter;
FTDCStartupParams ftdcStartupParams;
-void DiagnosticDataCollectionDirectoryPathServerParameter::append(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {
- b.append(name, ftdcDirectoryPathParameter->generic_string());
+void DiagnosticDataCollectionDirectoryPathServerParameter::append(
+ OperationContext* opCtx, BSONObjBuilder* b, StringData name, const boost::optional<TenantId>&) {
+ b->append(name, ftdcDirectoryPathParameter->generic_string());
}
-Status DiagnosticDataCollectionDirectoryPathServerParameter::setFromString(const std::string& str) {
+Status DiagnosticDataCollectionDirectoryPathServerParameter::setFromString(
+ StringData str, const boost::optional<TenantId>&) {
if (hasGlobalServiceContext()) {
FTDCController* controller = FTDCController::get(getGlobalServiceContext());
if (controller) {
- Status s = controller->setDirectory(str);
+ Status s = controller->setDirectory(str.toString());
if (!s.isOK()) {
return s;
}
}
}
- ftdcDirectoryPathParameter = str;
+ ftdcDirectoryPathParameter = str.toString();
return Status::OK();
}
diff --git a/src/mongo/db/global_settings.cpp b/src/mongo/db/global_settings.cpp
index 02508cbb5de..0d31094d87d 100644
--- a/src/mongo/db/global_settings.cpp
+++ b/src/mongo/db/global_settings.cpp
@@ -61,22 +61,24 @@ void ClusterNetworkRestrictionManager::set(
}
void AllowListedClusterNetworkSetting::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
auto allowlistedClusterNetwork =
std::atomic_load(&mongodGlobalParams.allowlistedClusterNetwork); // NOLINT
if (allowlistedClusterNetwork) {
- BSONArrayBuilder bb(b.subarrayStart(name));
+ BSONArrayBuilder bb(b->subarrayStart(name));
for (const auto& acn : *allowlistedClusterNetwork) {
bb << acn;
}
bb.doneFast();
} else {
- b << name << BSONNULL;
+ *b << name << BSONNULL;
}
}
-Status AllowListedClusterNetworkSetting::set(const mongo::BSONElement& e) {
+Status AllowListedClusterNetworkSetting::set(const mongo::BSONElement& e,
+ const boost::optional<TenantId>&) {
std::shared_ptr<std::vector<std::string>> allowlistedClusterNetwork;
if (e.isNull()) {
// noop
@@ -103,7 +105,8 @@ Status AllowListedClusterNetworkSetting::set(const mongo::BSONElement& e) {
return Status::OK();
}
-Status AllowListedClusterNetworkSetting::setFromString(const std::string& s) {
+Status AllowListedClusterNetworkSetting::setFromString(StringData s,
+ const boost::optional<TenantId>&) {
return {ErrorCodes::InternalError, "Cannot invoke this method"};
}
diff --git a/src/mongo/db/initialize_server_global_state.cpp b/src/mongo/db/initialize_server_global_state.cpp
index 240c2830fcb..02a30aac334 100644
--- a/src/mongo/db/initialize_server_global_state.cpp
+++ b/src/mongo/db/initialize_server_global_state.cpp
@@ -468,7 +468,8 @@ MONGO_INITIALIZER_GENERAL(MungeUmask, ("EndStartupOptionHandling"), ("ServerLogR
#endif
// --setParameter honorSystemUmask
-Status HonorSystemUMaskServerParameter::setFromString(const std::string& value) {
+Status HonorSystemUMaskServerParameter::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
#ifndef _WIN32
if ((value == "0") || (value == "false")) {
// false may be specified with processUmask
@@ -494,15 +495,17 @@ Status HonorSystemUMaskServerParameter::setFromString(const std::string& value)
}
void HonorSystemUMaskServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
#ifndef _WIN32
- b << name << honorSystemUmask;
+ *b << name << honorSystemUmask;
#endif
}
// --setParameter processUmask
-Status ProcessUMaskServerParameter::setFromString(const std::string& value) {
+Status ProcessUMaskServerParameter::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
#ifndef _WIN32
if (honorSystemUmask) {
return {ErrorCodes::BadValue,
@@ -510,7 +513,8 @@ Status ProcessUMaskServerParameter::setFromString(const std::string& value) {
}
// Convert base from octal
- const char* val = value.c_str();
+ auto vstr = value.toString();
+ const char* val = vstr.c_str();
char* end = nullptr;
auto mask = std::strtoul(val, &end, 8);
@@ -532,10 +536,11 @@ Status ProcessUMaskServerParameter::setFromString(const std::string& value) {
}
void ProcessUMaskServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
#ifndef _WIN32
- b << name << static_cast<int>(getUmaskOverride());
+ *b << name << static_cast<int>(getUmaskOverride());
#endif
}
diff --git a/src/mongo/db/mirror_maestro.cpp b/src/mongo/db/mirror_maestro.cpp
index e3bf69e9831..5be4cf1e0bc 100644
--- a/src/mongo/db/mirror_maestro.cpp
+++ b/src/mongo/db/mirror_maestro.cpp
@@ -249,13 +249,15 @@ auto parseMirroredReadsParameters(const BSONObj& obj) {
} // namespace
void MirroredReadsServerParameter::append(OperationContext*,
- BSONObjBuilder& bob,
- const std::string& name) {
- auto subBob = BSONObjBuilder(bob.subobjStart(name));
+ BSONObjBuilder* bob,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ auto subBob = BSONObjBuilder(bob->subobjStart(name));
_data->serialize(&subBob);
}
-Status MirroredReadsServerParameter::set(const BSONElement& value) try {
+Status MirroredReadsServerParameter::set(const BSONElement& value,
+ const boost::optional<TenantId>&) try {
auto obj = value.Obj();
_data = parseMirroredReadsParameters(obj);
@@ -265,7 +267,8 @@ Status MirroredReadsServerParameter::set(const BSONElement& value) try {
return e.toStatus();
}
-Status MirroredReadsServerParameter::setFromString(const std::string& str) try {
+Status MirroredReadsServerParameter::setFromString(StringData str,
+ const boost::optional<TenantId>&) try {
auto obj = fromjson(str);
_data = parseMirroredReadsParameters(obj);
diff --git a/src/mongo/db/process_health/fault_state_machine_test.cpp b/src/mongo/db/process_health/fault_state_machine_test.cpp
index 065ac057136..b25a357b34d 100644
--- a/src/mongo/db/process_health/fault_state_machine_test.cpp
+++ b/src/mongo/db/process_health/fault_state_machine_test.cpp
@@ -376,7 +376,7 @@ TEST_F(FaultManagerTest, DNSHealthCheckWithBadHostNameFailsAndGoodHostNameSucces
<< "interval" << 1000)));
const BSONObj newParameterObj = BSON("key" << bsonOBj);
auto element = newParameterObj.getField("key");
- uassertStatusOK(serverParam->set(element));
+ uassertStatusOK(serverParam->set(element, boost::none));
registerHealthObserver<DnsHealthObserver>();
globalFailPointRegistry()
diff --git a/src/mongo/db/process_health/health_monitoring_server_parameters.cpp b/src/mongo/db/process_health/health_monitoring_server_parameters.cpp
index 1f1c0a90d11..57c41b475ca 100644
--- a/src/mongo/db/process_health/health_monitoring_server_parameters.cpp
+++ b/src/mongo/db/process_health/health_monitoring_server_parameters.cpp
@@ -69,7 +69,8 @@ ConfigValues mergeConfigValues(const ConfigValues& oldValues, const ConfigValues
}
} // namespace
-Status HealthMonitoringIntensitiesServerParameter::setFromString(const std::string& value) {
+Status HealthMonitoringIntensitiesServerParameter::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
const auto oldValue = **_data;
auto newValue = HealthObserverIntensities::parse(
IDLParserContext("health monitoring intensities"), fromjson(value));
@@ -79,7 +80,8 @@ Status HealthMonitoringIntensitiesServerParameter::setFromString(const std::stri
return Status::OK();
}
-Status HealthMonitoringIntensitiesServerParameter::set(const BSONElement& newValueElement) {
+Status HealthMonitoringIntensitiesServerParameter::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>&) {
const auto oldValue = **_data;
auto newValue = HealthObserverIntensities::parse(
IDLParserContext("health monitoring intensities"), newValueElement.Obj());
@@ -90,34 +92,39 @@ Status HealthMonitoringIntensitiesServerParameter::set(const BSONElement& newVal
}
void HealthMonitoringIntensitiesServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
BSONObjBuilder healthMonitoring;
_data->serialize(&healthMonitoring);
- b.append(name, healthMonitoring.obj());
+ b->append(name, healthMonitoring.obj());
}
-Status HealthMonitoringProgressMonitorServerParameter::setFromString(const std::string& value) {
+Status HealthMonitoringProgressMonitorServerParameter::setFromString(
+ StringData value, const boost::optional<TenantId>&) {
*_data = HealthObserverProgressMonitorConfig::parse(
IDLParserContext("health monitoring liveness"), fromjson(value));
return Status::OK();
}
-Status HealthMonitoringProgressMonitorServerParameter::set(const BSONElement& newValueElement) {
+Status HealthMonitoringProgressMonitorServerParameter::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>&) {
*_data = HealthObserverProgressMonitorConfig::parse(
IDLParserContext("health monitoring liveness"), newValueElement.Obj());
return Status::OK();
}
void HealthMonitoringProgressMonitorServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
BSONObjBuilder healthMonitoring;
_data->serialize(&healthMonitoring);
- b.append(name, healthMonitoring.obj());
+ b->append(name, healthMonitoring.obj());
}
-Status PeriodicHealthCheckIntervalsServerParameter::setFromString(const std::string& value) {
+Status PeriodicHealthCheckIntervalsServerParameter::setFromString(
+ StringData value, const boost::optional<TenantId>&) {
const auto oldValue = **_data;
auto newValue = HealthObserverIntervals::parse(IDLParserContext("health monitoring interval"),
fromjson(value));
@@ -126,7 +133,8 @@ Status PeriodicHealthCheckIntervalsServerParameter::setFromString(const std::str
return Status::OK();
}
-Status PeriodicHealthCheckIntervalsServerParameter::set(const BSONElement& newValueElement) {
+Status PeriodicHealthCheckIntervalsServerParameter::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>&) {
const auto oldValue = **_data;
auto newValue = HealthObserverIntervals::parse(IDLParserContext("health monitoring interval"),
newValueElement.Obj());
@@ -136,11 +144,12 @@ Status PeriodicHealthCheckIntervalsServerParameter::set(const BSONElement& newVa
}
void PeriodicHealthCheckIntervalsServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
BSONObjBuilder healthMonitoring;
_data->serialize(&healthMonitoring);
- b.append(name, healthMonitoring.obj());
+ b->append(name, healthMonitoring.obj());
}
} // namespace mongo
diff --git a/src/mongo/db/query/ce_mode_parameter.cpp b/src/mongo/db/query/ce_mode_parameter.cpp
index 8c019d25746..2099c65ab1d 100644
--- a/src/mongo/db/query/ce_mode_parameter.cpp
+++ b/src/mongo/db/query/ce_mode_parameter.cpp
@@ -31,7 +31,7 @@
#include "mongo/db/query/query_knobs_gen.h"
namespace mongo::ce {
-Status validateCEMode(const std::string& value) {
+Status validateCEMode(const std::string& value, const boost::optional<TenantId>&) {
if (value == kHeuristic || value == kHistogram || value == kSampling) {
return Status::OK();
}
diff --git a/src/mongo/db/query/ce_mode_parameter.h b/src/mongo/db/query/ce_mode_parameter.h
index b267067747f..e103b82e927 100644
--- a/src/mongo/db/query/ce_mode_parameter.h
+++ b/src/mongo/db/query/ce_mode_parameter.h
@@ -32,6 +32,7 @@
#include <string>
#include "mongo/base/status.h"
+#include "mongo/db/tenant_id.h"
namespace mongo::ce {
@@ -42,6 +43,6 @@ const std::string kHeuristic = "heuristic";
const std::string kHistogram = "histogram";
const std::string kSampling = "sampling";
-Status validateCEMode(const std::string& value);
+Status validateCEMode(const std::string& value, const boost::optional<TenantId>&);
} // namespace mongo::ce
diff --git a/src/mongo/db/query/ce_mode_parameter_test.cpp b/src/mongo/db/query/ce_mode_parameter_test.cpp
index 66e4b23bc38..9769127e5b3 100644
--- a/src/mongo/db/query/ce_mode_parameter_test.cpp
+++ b/src/mongo/db/query/ce_mode_parameter_test.cpp
@@ -34,14 +34,14 @@
namespace mongo::ce {
TEST(CEModeParameterTest, ValidatesValidCEModes) {
- ASSERT_OK(validateCEMode("heuristic"));
- ASSERT_OK(validateCEMode("histogram"));
- ASSERT_OK(validateCEMode("sampling"));
+ ASSERT_OK(validateCEMode("heuristic", boost::none));
+ ASSERT_OK(validateCEMode("histogram", boost::none));
+ ASSERT_OK(validateCEMode("sampling", boost::none));
}
TEST(CEModeParameterTest, RejectsInvalidCEModes) {
- ASSERT_NOT_OK(validateCEMode("notamode"));
- ASSERT_NOT_OK(validateCEMode(""));
+ ASSERT_NOT_OK(validateCEMode("notamode", boost::none));
+ ASSERT_NOT_OK(validateCEMode("", boost::none));
}
} // namespace mongo::ce
diff --git a/src/mongo/db/query/framework_control.cpp b/src/mongo/db/query/framework_control.cpp
index cd35264a9b3..0a2f35dfb7f 100644
--- a/src/mongo/db/query/framework_control.cpp
+++ b/src/mongo/db/query/framework_control.cpp
@@ -33,11 +33,14 @@
namespace mongo {
-void QueryFrameworkControl::append(OperationContext*, BSONObjBuilder& b, const std::string& name) {
- b << name << QueryFrameworkControl_serializer(_data.get());
+void QueryFrameworkControl::append(OperationContext*,
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << QueryFrameworkControl_serializer(_data.get());
}
-Status QueryFrameworkControl::setFromString(const std::string& value) {
+Status QueryFrameworkControl::setFromString(StringData value, const boost::optional<TenantId>&) {
_data = QueryFrameworkControl_parse(IDLParserContext("internalQueryFrameworkControl"), value);
return Status::OK();
}
diff --git a/src/mongo/db/query/sbe_plan_cache_on_parameter_change.cpp b/src/mongo/db/query/sbe_plan_cache_on_parameter_change.cpp
index 399d5210128..b7ea17858d8 100644
--- a/src/mongo/db/query/sbe_plan_cache_on_parameter_change.cpp
+++ b/src/mongo/db/query/sbe_plan_cache_on_parameter_change.cpp
@@ -72,7 +72,7 @@ Status onPlanCacheSizeUpdate(const std::string& str) {
return Status::OK();
}
-Status validatePlanCacheSize(const std::string& str) {
+Status validatePlanCacheSize(const std::string& str, const boost::optional<TenantId>&) {
return PlanCacheSizeParameter::parse(str).getStatus();
}
diff --git a/src/mongo/db/query/sbe_plan_cache_on_parameter_change.h b/src/mongo/db/query/sbe_plan_cache_on_parameter_change.h
index e126dda9f48..fd7f090d766 100644
--- a/src/mongo/db/query/sbe_plan_cache_on_parameter_change.h
+++ b/src/mongo/db/query/sbe_plan_cache_on_parameter_change.h
@@ -45,7 +45,7 @@ Status onPlanCacheSizeUpdate(const std::string& str);
/**
* Callback called on validation of planCacheSize parameter.
*/
-Status validatePlanCacheSize(const std::string& str);
+Status validatePlanCacheSize(const std::string& str, const boost::optional<TenantId>&);
/**
* Clears the SBE plan cache. Used to implement 'clearSbeCacheOnParameterChange()' below.
diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp
index 4936d713489..7bc8da73f7a 100644
--- a/src/mongo/db/repl/initial_syncer_test.cpp
+++ b/src/mongo/db/repl/initial_syncer_test.cpp
@@ -4401,7 +4401,7 @@ TEST_F(InitialSyncerTest, TestRemainingInitialSyncEstimatedMillisMetric) {
auto opCtx = makeOpCtx();
ASSERT_OK(ServerParameterSet::getNodeParameterSet()
->get("collectionClonerBatchSize")
- ->setFromString("1"));
+ ->setFromString("1", boost::none));
_syncSourceSelector->setChooseNewSyncSourceResult_forTest(HostAndPort("localhost", 27017));
@@ -4561,7 +4561,7 @@ TEST_F(InitialSyncerTest, GetInitialSyncProgressReturnsCorrectProgress) {
auto opCtx = makeOpCtx();
ASSERT_OK(ServerParameterSet::getNodeParameterSet()
->get("collectionClonerBatchSize")
- ->setFromString("1"));
+ ->setFromString("1", boost::none));
_syncSourceSelector->setChooseNewSyncSourceResult_forTest(HostAndPort("localhost", 27017));
ASSERT_OK(initialSyncer->startup(opCtx.get(), 2U));
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index 868aa7691af..3cd9fa9c591 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -498,7 +498,7 @@ public:
if (auto param = ServerParameterSet::getNodeParameterSet()->getIfExists(
kAutomationServiceDescriptorFieldName)) {
- param->append(opCtx, result, kAutomationServiceDescriptorFieldName);
+ param->append(opCtx, &result, kAutomationServiceDescriptorFieldName, boost::none);
}
if (opCtx->getClient()->session()) {
diff --git a/src/mongo/db/s/config/configsvr_set_cluster_parameter_command.cpp b/src/mongo/db/s/config/configsvr_set_cluster_parameter_command.cpp
index 119eb61f4d0..19c8d947118 100644
--- a/src/mongo/db/s/config/configsvr_set_cluster_parameter_command.cpp
+++ b/src/mongo/db/s/config/configsvr_set_cluster_parameter_command.cpp
@@ -72,8 +72,12 @@ public:
SetClusterParameterInvocation invocation{std::move(sps), dbService};
- invocation.normalizeParameter(
- opCtx, cmdParamObj, boost::none, serverParameter, parameterName);
+ invocation.normalizeParameter(opCtx,
+ cmdParamObj,
+ boost::none,
+ serverParameter,
+ parameterName,
+ request().getDbName().tenantId());
SetClusterParameterCoordinatorDocument coordinatorDoc;
coordinatorDoc.setConfigsvrCoordinatorMetadata(
diff --git a/src/mongo/db/s/transaction_coordinator_test_fixture.cpp b/src/mongo/db/s/transaction_coordinator_test_fixture.cpp
index 7ccb3b5c439..a6aa349d58e 100644
--- a/src/mongo/db/s/transaction_coordinator_test_fixture.cpp
+++ b/src/mongo/db/s/transaction_coordinator_test_fixture.cpp
@@ -59,7 +59,7 @@ void TransactionCoordinatorTestFixture::setUp() {
ASSERT_OK(ServerParameterSet::getNodeParameterSet()
->get("logComponentVerbosity")
- ->setFromString("{transaction: {verbosity: 3}}"));
+ ->setFromString("{transaction: {verbosity: 3}}", boost::none));
for (const auto& shardId : kThreeShardIdList) {
auto shardTargeter = RemoteCommandTargeterMock::get(
diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp
index 677e279c9e7..29fd58cca46 100644
--- a/src/mongo/db/server_options_helpers.cpp
+++ b/src/mongo/db/server_options_helpers.cpp
@@ -271,12 +271,12 @@ StatusWith<BSONObj> applySetParameterOptions(const std::map<std::string, std::st
return Status(ErrorCodes::BadValue,
"Cannot use --setParameter to set \"{}\" at startup"_format(name));
BSONObjBuilder sub(summaryBuilder.subobjStart(name));
- sp->append(nullptr, sub, "default");
- Status status = sp->setFromString(value);
+ sp->append(nullptr, &sub, "default", boost::none);
+ Status status = sp->setFromString(value, boost::none);
if (!status.isOK())
return Status(ErrorCodes::BadValue,
"Bad value for parameter \"{}\": {}"_format(name, status.reason()));
- sp->append(nullptr, sub, "value");
+ sp->append(nullptr, &sub, "value", boost::none);
}
return summaryBuilder.obj();
}
diff --git a/src/mongo/db/server_options_test.cpp b/src/mongo/db/server_options_test.cpp
index f3d5c11c7a3..08f47e74ce8 100644
--- a/src/mongo/db/server_options_test.cpp
+++ b/src/mongo/db/server_options_test.cpp
@@ -867,11 +867,14 @@ public:
TestServerParameter(StringData name, ServerParameterType spt, int x)
: ServerParameter(name, spt), val{x} {}
- void append(OperationContext*, BSONObjBuilder& bob, const std::string& name) final {
- bob.append(name, val);
+ void append(OperationContext*,
+ BSONObjBuilder* bob,
+ StringData name,
+ const boost::optional<TenantId>&) final {
+ bob->append(name, val);
}
- Status setFromString(const std::string& str) final {
+ Status setFromString(StringData str, const boost::optional<TenantId>&) final {
int value;
Status status = NumberParser{}(str, &value);
if (!status.isOK())
diff --git a/src/mongo/db/server_parameter.cpp b/src/mongo/db/server_parameter.cpp
index 553eb6d199f..9e70ab3aac1 100644
--- a/src/mongo/db/server_parameter.cpp
+++ b/src/mongo/db/server_parameter.cpp
@@ -49,8 +49,9 @@ MONGO_INITIALIZER_GROUP(EndServerParameterRegistration,
ServerParameter::ServerParameter(StringData name, ServerParameterType spt)
: _name{name}, _type(spt) {}
-Status ServerParameter::set(const BSONElement& newValueElement) {
- auto validateStatus = validate(newValueElement);
+Status ServerParameter::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId) {
+ auto validateStatus = validate(newValueElement, tenantId);
if (!validateStatus.isOK()) {
return validateStatus;
}
@@ -58,7 +59,7 @@ Status ServerParameter::set(const BSONElement& newValueElement) {
auto swValue = _coerceToString(newValueElement);
if (!swValue.isOK())
return swValue.getStatus();
- return setFromString(swValue.getValue());
+ return setFromString(swValue.getValue(), boost::none);
}
ServerParameterSet* ServerParameterSet::getNodeParameterSet() {
@@ -134,45 +135,48 @@ IDLServerParameterDeprecatedAlias::IDLServerParameterDeprecatedAlias(StringData
}
void IDLServerParameterDeprecatedAlias::append(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& fieldName) {
+ BSONObjBuilder* b,
+ StringData fieldName,
+ const boost::optional<TenantId>& tenantId) {
std::call_once(_warnOnce, [&] {
LOGV2_WARNING(636300,
"Use of deprecated server parameter name",
"deprecatedName"_attr = name(),
"canonicalName"_attr = _sp->name());
});
- _sp->append(opCtx, b, fieldName);
+ _sp->append(opCtx, b, fieldName, tenantId);
}
-Status IDLServerParameterDeprecatedAlias::reset() {
+Status IDLServerParameterDeprecatedAlias::reset(const boost::optional<TenantId>& tenantId) {
std::call_once(_warnOnce, [&] {
LOGV2_WARNING(636301,
"Use of deprecated server parameter name",
"deprecatedName"_attr = name(),
"canonicalName"_attr = _sp->name());
});
- return _sp->reset();
+ return _sp->reset(tenantId);
}
-Status IDLServerParameterDeprecatedAlias::set(const BSONElement& newValueElement) {
+Status IDLServerParameterDeprecatedAlias::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId) {
std::call_once(_warnOnce, [&] {
LOGV2_WARNING(636302,
"Use of deprecated server parameter name",
"deprecatedName"_attr = name(),
"canonicalName"_attr = _sp->name());
});
- return _sp->set(newValueElement);
+ return _sp->set(newValueElement, tenantId);
}
-Status IDLServerParameterDeprecatedAlias::setFromString(const std::string& str) {
+Status IDLServerParameterDeprecatedAlias::setFromString(StringData str,
+ const boost::optional<TenantId>& tenantId) {
std::call_once(_warnOnce, [&] {
LOGV2_WARNING(636303,
"Use of deprecated server parameter name",
"deprecatedName"_attr = name(),
"canonicalName"_attr = _sp->name());
});
- return _sp->setFromString(str);
+ return _sp->setFromString(str, tenantId);
}
namespace {
@@ -181,24 +185,28 @@ public:
explicit DisabledTestParameter(ServerParameter* sp)
: ServerParameter(sp->name(), sp->getServerParameterType()), _sp(sp) {}
- void append(OperationContext* opCtx, BSONObjBuilder& b, const std::string& name) final {}
+ void append(OperationContext* opCtx,
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) final {}
- Status validate(const BSONElement& newValueElement) const final {
+ Status validate(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId) const final {
return {ErrorCodes::BadValue,
str::stream() << "Server parameter: '" << name() << "' is currently disabled"};
}
- Status setFromString(const std::string&) final {
+ Status setFromString(StringData, const boost::optional<TenantId>&) final {
return {ErrorCodes::BadValue,
str::stream() << "Server parameter: '" << name() << "' is currently disabled"};
}
- Status set(const BSONElement& newValueElement) final {
- return setFromString("");
+ Status set(const BSONElement& newValueElement, const boost::optional<TenantId>&) final {
+ return setFromString("", boost::none);
}
- Status reset() final {
- return setFromString("");
+ Status reset(const boost::optional<TenantId>&) final {
+ return setFromString("", boost::none);
}
bool isEnabled() const override {
diff --git a/src/mongo/db/server_parameter.h b/src/mongo/db/server_parameter.h
index 71960aa91a6..0f69433e9f3 100644
--- a/src/mongo/db/server_parameter.h
+++ b/src/mongo/db/server_parameter.h
@@ -43,6 +43,7 @@
#include "mongo/bson/bsonelement.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/logical_time.h"
+#include "mongo/db/tenant_id.h"
#define MONGO_SERVER_PARAMETER_REGISTER(name) \
MONGO_INITIALIZER_GENERAL( \
@@ -130,25 +131,31 @@ public:
return (_type != ServerParameterType::kClusterWide);
}
- virtual void append(OperationContext* opCtx, BSONObjBuilder& b, const std::string& name) = 0;
+ virtual void append(OperationContext* opCtx,
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>& tenantId) = 0;
virtual void appendSupportingRoundtrip(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {
- append(opCtx, b, name);
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>& tenantId) {
+ append(opCtx, b, name, tenantId);
}
- virtual Status validate(const BSONElement& newValueElement) const {
+ virtual Status validate(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId) const {
return Status::OK();
}
- Status validate(const BSONObj& newValueObj) const {
- return validate(BSON("" << newValueObj).firstElement());
+ Status validate(const BSONObj& newValueObj, const boost::optional<TenantId>& tenantId) const {
+ return validate(BSON("" << newValueObj).firstElement(), tenantId);
}
// This base implementation calls `setFromString(coerceToString(newValueElement))`.
// Derived classes may customize the behavior by specifying `override_set` in IDL.
- virtual Status set(const BSONElement& newValueElement);
+ virtual Status set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId);
/**
* This method will reset the server parameter's value back to its default. This is currently
@@ -162,7 +169,7 @@ public:
* method. If it is called without being implemented, it will return an error via the inherited
* method below.
*/
- virtual Status reset() {
+ virtual Status reset(const boost::optional<TenantId>& tenantId) {
return Status{ErrorCodes::OperationFailed,
str::stream()
<< "Parameter reset not implemented for server parameter: " << name()};
@@ -172,11 +179,11 @@ public:
* Overload of set() that accepts BSONObjs instead of BSONElements. This is currently only used
* for cluster server parameters but can be used for node-only server parameters.
*/
- Status set(const BSONObj& newValueObj) {
- return set(BSON("" << newValueObj).firstElement());
+ Status set(const BSONObj& newValueObj, const boost::optional<TenantId>& tenantId) {
+ return set(BSON("" << newValueObj).firstElement(), tenantId);
}
- virtual Status setFromString(const std::string& str) = 0;
+ virtual Status setFromString(StringData str, const boost::optional<TenantId>& tenantId) = 0;
/**
* Simply returns the uninitialized/default-constructed LogicalTime by default.
@@ -186,8 +193,8 @@ public:
* implement a mechanism for atomically setting the clusterParameterTime in the set() method and
* retrieving it via this method.
*/
- virtual LogicalTime getClusterParameterTime() const {
- return LogicalTime::kUninitialized;
+ virtual LogicalTime getClusterParameterTime(const boost::optional<TenantId>& tenantId) const {
+ MONGO_UNREACHABLE;
}
bool isTestOnly() const {
@@ -293,10 +300,13 @@ class IDLServerParameterDeprecatedAlias : public ServerParameter {
public:
IDLServerParameterDeprecatedAlias(StringData name, ServerParameter* sp);
- void append(OperationContext* opCtx, BSONObjBuilder& b, const std::string& name) final;
- Status reset() final;
- Status set(const BSONElement& newValueElement) final;
- Status setFromString(const std::string& str) final;
+ void append(OperationContext* opCtx,
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>& tenantId) final;
+ Status reset(const boost::optional<TenantId>& tenantId) final;
+ Status set(const BSONElement& newValueElement, const boost::optional<TenantId>& tenantId) final;
+ Status setFromString(StringData str, const boost::optional<TenantId>& tenantId) final;
private:
std::once_flag _warnOnce;
diff --git a/src/mongo/db/server_parameter_with_storage.h b/src/mongo/db/server_parameter_with_storage.h
index b0ad2fb7f08..6e39fe27576 100644
--- a/src/mongo/db/server_parameter_with_storage.h
+++ b/src/mongo/db/server_parameter_with_storage.h
@@ -319,9 +319,10 @@ public:
IDLServerParameterWithStorage(StringData name, T& storage)
: ServerParameter(name, paramType), _storage(storage) {}
- Status validateValue(const element_type& newValue) const {
+ Status validateValue(const element_type& newValue,
+ const boost::optional<TenantId>& tenantId) const {
for (const auto& validator : _validators) {
- const auto status = validator(newValue);
+ const auto status = validator(newValue, tenantId);
if (!status.isOK()) {
return status;
}
@@ -332,12 +333,12 @@ public:
/**
* Convenience wrapper for storing a value.
*/
- Status setValue(const element_type& newValue) {
- if (auto status = validateValue(newValue); !status.isOK()) {
+ Status setValue(const element_type& newValue, const boost::optional<TenantId>& tenantId) {
+ if (auto status = validateValue(newValue, tenantId); !status.isOK()) {
return status;
}
- _storage.store(newValue, boost::none);
+ _storage.store(newValue, tenantId);
if (_onUpdate) {
return _onUpdate(newValue);
@@ -349,8 +350,8 @@ public:
/**
* Convenience wrapper for fetching value from storage.
*/
- element_type getValue() const {
- return _storage.load(boost::none);
+ element_type getValue(const boost::optional<TenantId>& tenantId) const {
+ return _storage.load(tenantId);
}
/**
@@ -367,7 +368,7 @@ public:
// Update the actual storage, performing validation and any post-update functions as
// necessary.
- status = reset();
+ status = reset(boost::none);
});
return status;
}
@@ -378,14 +379,17 @@ public:
* Typically invoked by {getParameter:...} or {getClusterParameter:...} to produce a dictionary
* of SCP settings.
*/
- void append(OperationContext* opCtx, BSONObjBuilder& b, const std::string& name) final {
+ void append(OperationContext* opCtx,
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>& tenantId) final {
if (isRedact()) {
- b.append(name, "###");
+ b->append(name, "###");
} else if constexpr (paramType == SPT::kClusterWide) {
- b.append("_id"_sd, name);
- b.appendElementsUnique(getValue().toBSON());
+ b->append("_id"_sd, name);
+ b->appendElementsUnique(getValue(tenantId).toBSON());
} else {
- b.append(name, getValue());
+ b->append(name, getValue(tenantId));
}
}
@@ -409,13 +413,14 @@ public:
return newValue;
}
- Status validate(const BSONElement& newValueElement) const final {
+ Status validate(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId) const final {
StatusWith<element_type> swNewValue = parseElement(newValueElement);
if (!swNewValue.isOK()) {
return swNewValue.getStatus();
}
- return validateValue(swNewValue.getValue());
+ return validateValue(swNewValue.getValue(), tenantId);
}
/**
@@ -424,22 +429,23 @@ public:
* Allows setting non-basic values (e.g. vector<string>)
* via the {setParameter: ...} call or {setClusterParameter: ...} call.
*/
- Status set(const BSONElement& newValueElement) final {
+ Status set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId) final {
StatusWith<element_type> swNewValue = parseElement(newValueElement);
if (!swNewValue.isOK()) {
return swNewValue.getStatus();
}
- return setValue(swNewValue.getValue());
+ return setValue(swNewValue.getValue(), tenantId);
}
/**
* Resets the current storage value in storage_wrapper with the default value.
*/
- Status reset() final {
- _storage.reset(boost::none);
+ Status reset(const boost::optional<TenantId>& tenantId) final {
+ _storage.reset(tenantId);
if (_onUpdate) {
- return _onUpdate(_storage.load(boost::none));
+ return _onUpdate(_storage.load(tenantId));
}
return Status::OK();
@@ -451,7 +457,7 @@ public:
* Typically invoked from commandline --setParameter usage. Prohibited for cluster server
* parameters.
*/
- Status setFromString(const std::string& str) final {
+ Status setFromString(StringData str, const boost::optional<TenantId>& tenantId) final {
if constexpr (paramType == SPT::kClusterWide) {
return {ErrorCodes::BadValue,
"Unable to set a cluster-wide server parameter from the command line or config "
@@ -462,7 +468,7 @@ public:
return swNewValue.getStatus();
}
- return setValue(swNewValue.getValue());
+ return setValue(swNewValue.getValue(), tenantId);
}
}
@@ -470,9 +476,9 @@ public:
* Retrieves the cluster parameter time from the chained ClusterServerParameter struct in
* storage. All other server parameters simply return the uninitialized LogicalTime.
*/
- LogicalTime getClusterParameterTime() const final {
+ LogicalTime getClusterParameterTime(const boost::optional<TenantId>& tenantId) const final {
if constexpr (hasClusterServerParameter<element_type>) {
- return getValue().getClusterParameterTime();
+ return getValue(tenantId).getClusterParameterTime();
}
return LogicalTime::kUninitialized;
@@ -493,7 +499,7 @@ public:
*
* Callback should return Status::OK() or ErrorCodes::BadValue.
*/
- using validator_t = Status(const element_type&);
+ using validator_t = Status(const element_type&, const boost::optional<TenantId>& tenantId);
void addValidator(std::function<validator_t> validator) {
_validators.push_back(std::move(validator));
}
@@ -503,15 +509,16 @@ public:
*/
template <class predicate>
void addBound(const element_type& bound) {
- addValidator([bound, spname = name()](const element_type& value) {
- if (!predicate::evaluate(value, bound)) {
- return Status(ErrorCodes::BadValue,
- str::stream()
- << "Invalid value for parameter " << spname << ": " << value
- << " is not " << predicate::description << " " << bound);
- }
- return Status::OK();
- });
+ addValidator(
+ [bound, spname = name()](const element_type& value, const boost::optional<TenantId>&) {
+ if (!predicate::evaluate(value, bound)) {
+ return Status(ErrorCodes::BadValue,
+ str::stream()
+ << "Invalid value for parameter " << spname << ": " << value
+ << " is not " << predicate::description << " " << bound);
+ }
+ return Status::OK();
+ });
}
private:
diff --git a/src/mongo/db/storage/storage_engine_parameters.cpp b/src/mongo/db/storage/storage_engine_parameters.cpp
index f49ab161253..e1c164315aa 100644
--- a/src/mongo/db/storage/storage_engine_parameters.cpp
+++ b/src/mongo/db/storage/storage_engine_parameters.cpp
@@ -34,12 +34,14 @@ namespace mongo {
QueueingPolicyEnum gTicketQueueingPolicy{QueueingPolicyEnum::FifoQueue};
void TicketQueueingPolicy::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& name) {
- builder.append(name, QueueingPolicy_serializer(gTicketQueueingPolicy));
+ BSONObjBuilder* builder,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ builder->append(name, QueueingPolicy_serializer(gTicketQueueingPolicy));
}
-Status TicketQueueingPolicy::setFromString(const std::string& protocolStr) {
+Status TicketQueueingPolicy::setFromString(StringData protocolStr,
+ const boost::optional<TenantId>&) {
if (protocolStr == QueueingPolicy_serializer(QueueingPolicyEnum::Semaphore)) {
gTicketQueueingPolicy = QueueingPolicyEnum::Semaphore;
} else if (protocolStr == QueueingPolicy_serializer(QueueingPolicyEnum::FifoQueue)) {
diff --git a/src/mongo/db/storage/storage_options.cpp b/src/mongo/db/storage/storage_options.cpp
index 3736cd69316..5df2299e0ab 100644
--- a/src/mongo/db/storage/storage_options.cpp
+++ b/src/mongo/db/storage/storage_options.cpp
@@ -62,15 +62,16 @@ void StorageGlobalParams::reset() {
StorageGlobalParams storageGlobalParams;
-Status StorageDirectoryPerDbParameter::setFromString(const std::string&) {
+Status StorageDirectoryPerDbParameter::setFromString(StringData, const boost::optional<TenantId>&) {
return {ErrorCodes::IllegalOperation,
str::stream() << name() << " cannot be set via setParameter"};
};
void StorageDirectoryPerDbParameter::append(OperationContext* opCtx,
- BSONObjBuilder& builder,
- const std::string& name) {
- builder.append(name, storageGlobalParams.directoryperdb);
+ BSONObjBuilder* builder,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ builder->append(name, storageGlobalParams.directoryperdb);
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_parameters.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_parameters.cpp
index 02831180a11..2ec7d42e175 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_parameters.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_parameters.cpp
@@ -42,12 +42,14 @@ namespace mongo {
using std::string;
void WiredTigerEngineRuntimeConfigParameter::append(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {
- b << name << _data.first;
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << _data.first;
}
-Status WiredTigerEngineRuntimeConfigParameter::setFromString(const std::string& str) {
+Status WiredTigerEngineRuntimeConfigParameter::setFromString(StringData str,
+ const boost::optional<TenantId>&) {
size_t pos = str.find('\0');
if (pos != std::string::npos) {
return Status(ErrorCodes::BadValue,
@@ -63,7 +65,7 @@ Status WiredTigerEngineRuntimeConfigParameter::setFromString(const std::string&
"config"_attr = str);
invariant(_data.second);
- int ret = _data.second->reconfigure(str.c_str());
+ int ret = _data.second->reconfigure(str.toString().c_str());
if (ret != 0) {
const char* errorStr = wiredtiger_strerror(ret);
string result = (str::stream() << "WiredTiger reconfiguration failed with error code ("
@@ -76,18 +78,20 @@ Status WiredTigerEngineRuntimeConfigParameter::setFromString(const std::string&
return Status(ErrorCodes::BadValue, result);
}
- _data.first = str;
+ _data.first = str.toString();
return Status::OK();
}
-Status WiredTigerDirectoryForIndexesParameter::setFromString(const std::string&) {
+Status WiredTigerDirectoryForIndexesParameter::setFromString(StringData,
+ const boost::optional<TenantId>&) {
return {ErrorCodes::IllegalOperation,
str::stream() << name() << " cannot be set via setParameter"};
};
void WiredTigerDirectoryForIndexesParameter::append(OperationContext* opCtx,
- BSONObjBuilder& builder,
- const std::string& name) {
- builder.append(name, wiredTigerGlobalOptions.directoryForIndexes);
+ BSONObjBuilder* builder,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ builder->append(name, wiredTigerGlobalOptions.directoryForIndexes);
}
} // namespace mongo
diff --git a/src/mongo/db/traffic_recorder_validators.cpp b/src/mongo/db/traffic_recorder_validators.cpp
index c9c48501e8d..c74075f7738 100644
--- a/src/mongo/db/traffic_recorder_validators.cpp
+++ b/src/mongo/db/traffic_recorder_validators.cpp
@@ -35,7 +35,7 @@
namespace mongo {
-Status validateTrafficRecordDestination(const std::string& path) {
+Status validateTrafficRecordDestination(const std::string& path, const boost::optional<TenantId>&) {
if (!path.empty() && !boost::filesystem::is_directory(path)) {
return Status(ErrorCodes::FileNotOpen,
str::stream()
diff --git a/src/mongo/db/traffic_recorder_validators.h b/src/mongo/db/traffic_recorder_validators.h
index 94e2c10bff6..532280e203c 100644
--- a/src/mongo/db/traffic_recorder_validators.h
+++ b/src/mongo/db/traffic_recorder_validators.h
@@ -29,13 +29,15 @@
#pragma once
+#include <boost/optional.hpp>
#include <string>
#include "mongo/base/status.h"
+#include "mongo/db/tenant_id.h"
namespace mongo {
-Status validateTrafficRecordDestination(const std::string& path);
+Status validateTrafficRecordDestination(const std::string& path, const boost::optional<TenantId>&);
} // namespace mongo
diff --git a/src/mongo/dbtests/framework_options.cpp b/src/mongo/dbtests/framework_options.cpp
index 9715ecacc15..2ab6f22d148 100644
--- a/src/mongo/dbtests/framework_options.cpp
+++ b/src/mongo/dbtests/framework_options.cpp
@@ -155,7 +155,7 @@ Status storeTestFrameworkOptions(const moe::Environment& params,
str::stream() << "Cannot use --setParameter to set \"" << it.first
<< "\" at startup"};
}
- Status status = parameter->setFromString(it.second);
+ Status status = parameter->setFromString(it.second, boost::none);
if (!status.isOK()) {
return {ErrorCodes::BadValue,
str::stream() << "Bad value for parameter \"" << it.first
diff --git a/src/mongo/idl/cluster_server_parameter_initializer.cpp b/src/mongo/idl/cluster_server_parameter_initializer.cpp
index 0874926546d..79ce79dc9eb 100644
--- a/src/mongo/idl/cluster_server_parameter_initializer.cpp
+++ b/src/mongo/idl/cluster_server_parameter_initializer.cpp
@@ -95,26 +95,26 @@ void ClusterServerParameterInitializer::updateParameter(OperationContext* opCtx,
}
BSONObjBuilder oldValueBob;
- sp->append(opCtx, oldValueBob, name.toString());
+ sp->append(opCtx, &oldValueBob, name.toString(), boost::none);
audit::logUpdateCachedClusterParameter(opCtx->getClient(), oldValueBob.obj(), doc);
- uassertStatusOK(sp->set(doc));
+ uassertStatusOK(sp->set(doc, boost::none));
}
void ClusterServerParameterInitializer::clearParameter(OperationContext* opCtx,
ServerParameter* sp) {
- if (sp->getClusterParameterTime() == LogicalTime::kUninitialized) {
+ if (sp->getClusterParameterTime(boost::none) == LogicalTime::kUninitialized) {
// Nothing to clear.
return;
}
BSONObjBuilder oldValueBob;
- sp->append(opCtx, oldValueBob, sp->name());
+ sp->append(opCtx, &oldValueBob, sp->name(), boost::none);
- uassertStatusOK(sp->reset());
+ uassertStatusOK(sp->reset(boost::none));
BSONObjBuilder newValueBob;
- sp->append(opCtx, newValueBob, sp->name());
+ sp->append(opCtx, &newValueBob, sp->name(), boost::none);
audit::logUpdateCachedClusterParameter(
opCtx->getClient(), oldValueBob.obj(), newValueBob.obj());
diff --git a/src/mongo/idl/cluster_server_parameter_initializer_test.cpp b/src/mongo/idl/cluster_server_parameter_initializer_test.cpp
index b2ba65c7739..fd9e1a8234d 100644
--- a/src/mongo/idl/cluster_server_parameter_initializer_test.cpp
+++ b/src/mongo/idl/cluster_server_parameter_initializer_test.cpp
@@ -93,7 +93,7 @@ TEST_F(ClusterServerParameterInitializerTest, OnInitialSync) {
->get<IDLServerParameterWithStorage<ServerParameterType::kClusterWide,
ClusterServerParameterTest>>(kCSPTest);
ASSERT(sp != nullptr);
- ClusterServerParameterTest cspTest = sp->getValue();
+ ClusterServerParameterTest cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kDefaultIntValue);
ASSERT_EQ(cspTest.getStrValue(), kDefaultStrValue);
@@ -104,7 +104,7 @@ TEST_F(ClusterServerParameterInitializerTest, OnInitialSync) {
->get<IDLServerParameterWithStorage<ServerParameterType::kClusterWide,
ClusterServerParameterTest>>(kCSPTest);
ASSERT(sp != nullptr);
- cspTest = sp->getValue();
+ cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kInitialIntValue);
ASSERT_EQ(cspTest.getStrValue(), kInitialStrValue);
}
@@ -115,7 +115,7 @@ TEST_F(ClusterServerParameterInitializerTest, OnStartupRecovery) {
->get<IDLServerParameterWithStorage<ServerParameterType::kClusterWide,
ClusterServerParameterTest>>(kCSPTest);
ASSERT(sp != nullptr);
- ClusterServerParameterTest cspTest = sp->getValue();
+ ClusterServerParameterTest cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kDefaultIntValue);
ASSERT_EQ(cspTest.getStrValue(), kDefaultStrValue);
@@ -126,7 +126,7 @@ TEST_F(ClusterServerParameterInitializerTest, OnStartupRecovery) {
->get<IDLServerParameterWithStorage<ServerParameterType::kClusterWide,
ClusterServerParameterTest>>(kCSPTest);
ASSERT(sp != nullptr);
- cspTest = sp->getValue();
+ cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kInitialIntValue);
ASSERT_EQ(cspTest.getStrValue(), kInitialStrValue);
}
diff --git a/src/mongo/idl/cluster_server_parameter_op_observer_test.cpp b/src/mongo/idl/cluster_server_parameter_op_observer_test.cpp
index a4cbb48d151..3b149fdae2c 100644
--- a/src/mongo/idl/cluster_server_parameter_op_observer_test.cpp
+++ b/src/mongo/idl/cluster_server_parameter_op_observer_test.cpp
@@ -133,12 +133,12 @@ public:
ClusterServerParameterTest>>(kCSPTest);
ASSERT(sp != nullptr);
- const auto initialCPTime = sp->getClusterParameterTime();
- ClusterServerParameterTest initialCspTest = sp->getValue();
+ const auto initialCPTime = sp->getClusterParameterTime(boost::none);
+ ClusterServerParameterTest initialCspTest = sp->getValue(boost::none);
fn(nss);
- ClusterServerParameterTest finalCspTest = sp->getValue();
+ ClusterServerParameterTest finalCspTest = sp->getValue(boost::none);
- ASSERT_EQ(sp->getClusterParameterTime(), initialCPTime);
+ ASSERT_EQ(sp->getClusterParameterTime(boost::none), initialCPTime);
ASSERT_EQ(finalCspTest.getIntValue(), initialCspTest.getIntValue());
ASSERT_EQ(finalCspTest.getStrValue(), initialCspTest.getStrValue());
}
@@ -156,7 +156,7 @@ public:
ClusterServerParameterTest>>(kCSPTest);
ASSERT(sp != nullptr);
- ClusterServerParameterTest cspTest = sp->getValue();
+ ClusterServerParameterTest cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kInitialIntValue);
ASSERT_EQ(cspTest.getStrValue(), kInitialStrValue);
@@ -189,17 +189,17 @@ TEST_F(ClusterServerParameterOpObserverTest, OnInsertRecord) {
ASSERT(sp != nullptr);
// Single record insert.
- const auto initialLogicalTime = sp->getClusterParameterTime();
+ const auto initialLogicalTime = sp->getClusterParameterTime(boost::none);
const auto singleLogicalTime = initialLogicalTime.addTicks(1);
- const auto singleIntValue = sp->getValue().getIntValue() + 1;
+ const auto singleIntValue = sp->getValue(boost::none).getIntValue() + 1;
const auto singleStrValue = "OnInsertRecord.single";
ASSERT_LT(initialLogicalTime, singleLogicalTime);
doInserts(NamespaceString::kClusterParametersNamespace,
{makeClusterParametersDoc(singleLogicalTime, singleIntValue, singleStrValue)});
- ClusterServerParameterTest cspTest = sp->getValue();
- ASSERT_EQ(sp->getClusterParameterTime(), singleLogicalTime);
+ ClusterServerParameterTest cspTest = sp->getValue(boost::none);
+ ASSERT_EQ(sp->getClusterParameterTime(boost::none), singleLogicalTime);
ASSERT_EQ(cspTest.getIntValue(), singleIntValue);
ASSERT_EQ(cspTest.getStrValue(), singleStrValue);
@@ -216,8 +216,8 @@ TEST_F(ClusterServerParameterOpObserverTest, OnInsertRecord) {
BSON(ClusterServerParameter::k_idFieldName << "alsoIgnored"),
});
- cspTest = sp->getValue();
- ASSERT_EQ(sp->getClusterParameterTime(), multiLogicalTime);
+ cspTest = sp->getValue(boost::none);
+ ASSERT_EQ(sp->getClusterParameterTime(boost::none), multiLogicalTime);
ASSERT_EQ(cspTest.getIntValue(), multiIntValue);
ASSERT_EQ(cspTest.getStrValue(), multiStrValue);
@@ -257,17 +257,17 @@ TEST_F(ClusterServerParameterOpObserverTest, OnUpdateRecord) {
ASSERT(sp != nullptr);
// Single record update.
- const auto initialLogicalTime = sp->getClusterParameterTime();
+ const auto initialLogicalTime = sp->getClusterParameterTime(boost::none);
const auto singleLogicalTime = initialLogicalTime.addTicks(1);
- const auto singleIntValue = sp->getValue().getIntValue() + 1;
+ const auto singleIntValue = sp->getValue(boost::none).getIntValue() + 1;
const auto singleStrValue = "OnUpdateRecord.single";
ASSERT_LT(initialLogicalTime, singleLogicalTime);
doUpdate(NamespaceString::kClusterParametersNamespace,
makeClusterParametersDoc(singleLogicalTime, singleIntValue, singleStrValue));
- ClusterServerParameterTest cspTest = sp->getValue();
- ASSERT_EQ(sp->getClusterParameterTime(), singleLogicalTime);
+ ClusterServerParameterTest cspTest = sp->getValue(boost::none);
+ ASSERT_EQ(sp->getClusterParameterTime(boost::none), singleLogicalTime);
ASSERT_EQ(cspTest.getIntValue(), singleIntValue);
ASSERT_EQ(cspTest.getStrValue(), singleStrValue);
@@ -301,7 +301,7 @@ TEST_F(ClusterServerParameterOpObserverTest, onDeleteRecord) {
// Reset configuration to defaults when we claim to have deleted the doc.
doDelete(NamespaceString::kClusterParametersNamespace, initialDoc);
- ClusterServerParameterTest cspTest = sp->getValue();
+ ClusterServerParameterTest cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kDefaultIntValue);
ASSERT_EQ(cspTest.getStrValue(), kDefaultStrValue);
@@ -309,7 +309,7 @@ TEST_F(ClusterServerParameterOpObserverTest, onDeleteRecord) {
// Restore configured state, and delete without including deleteDoc reference.
initializeState();
doDelete(NamespaceString::kClusterParametersNamespace, initialDoc, false);
- cspTest = sp->getValue();
+ cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kDefaultIntValue);
ASSERT_EQ(cspTest.getStrValue(), kDefaultStrValue);
}
@@ -333,7 +333,7 @@ TEST_F(ClusterServerParameterOpObserverTest, onDropDatabase) {
ClusterServerParameterTest>>(kCSPTest);
ASSERT(sp != nullptr);
- ClusterServerParameterTest cspTest = sp->getValue();
+ ClusterServerParameterTest cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kDefaultIntValue);
ASSERT_EQ(cspTest.getStrValue(), kDefaultStrValue);
}
@@ -356,13 +356,13 @@ TEST_F(ClusterServerParameterOpObserverTest, onRenameCollection) {
// Rename away (and reset to default)
doRenameCollection(NamespaceString::kClusterParametersNamespace, kTestFoo);
- ClusterServerParameterTest cspTest = sp->getValue();
+ ClusterServerParameterTest cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kDefaultIntValue);
ASSERT_EQ(cspTest.getStrValue(), kDefaultStrValue);
// Rename in (and restore to initialized state)
doRenameCollection(kTestFoo, NamespaceString::kClusterParametersNamespace);
- cspTest = sp->getValue();
+ cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kInitialIntValue);
ASSERT_EQ(cspTest.getStrValue(), kInitialStrValue);
}
@@ -384,7 +384,7 @@ TEST_F(ClusterServerParameterOpObserverTest, onImportCollection) {
makeClusterParametersDoc(LogicalTime(Timestamp(time(nullptr))), 333, "onImportCollection");
upsert(doc);
doImportCollection(NamespaceString::kClusterParametersNamespace);
- ClusterServerParameterTest cspTest = sp->getValue();
+ ClusterServerParameterTest cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), 333);
ASSERT_EQ(cspTest.getStrValue(), "onImportCollection");
}
@@ -404,14 +404,14 @@ TEST_F(ClusterServerParameterOpObserverTest, onReplicationRollback) {
// Trigger rollback of ignorable namespaces.
doReplicationRollback(kIgnoredNamespaces);
- ClusterServerParameterTest cspTest = sp->getValue();
+ ClusterServerParameterTest cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kInitialIntValue);
ASSERT_EQ(cspTest.getStrValue(), kInitialStrValue);
// Trigger rollback of relevant namespace.
remove();
doReplicationRollback({NamespaceString::kClusterParametersNamespace});
- cspTest = sp->getValue();
+ cspTest = sp->getValue(boost::none);
ASSERT_EQ(cspTest.getIntValue(), kDefaultIntValue);
ASSERT_EQ(cspTest.getStrValue(), kDefaultStrValue);
@@ -419,7 +419,7 @@ TEST_F(ClusterServerParameterOpObserverTest, onReplicationRollback) {
auto doc = makeClusterParametersDoc(
LogicalTime(Timestamp(time(nullptr))), 444, "onReplicationRollback");
upsert(doc);
- cspTest = sp->getValue();
+ cspTest = sp->getValue(boost::none);
doReplicationRollback({NamespaceString::kClusterParametersNamespace});
ASSERT_EQ(cspTest.getIntValue(), kDefaultIntValue);
ASSERT_EQ(cspTest.getStrValue(), kDefaultStrValue);
diff --git a/src/mongo/idl/cluster_server_parameter_refresher.cpp b/src/mongo/idl/cluster_server_parameter_refresher.cpp
index 42f49040305..efede10b74d 100644
--- a/src/mongo/idl/cluster_server_parameter_refresher.cpp
+++ b/src/mongo/idl/cluster_server_parameter_refresher.cpp
@@ -143,9 +143,9 @@ Status ClusterServerParameterRefresher::refreshParameters(OperationContext* opCt
ServerParameter* sp = clusterParameterCache->get(clusterParameterName);
BSONObjBuilder oldClusterParameterBob;
- sp->append(opCtx, oldClusterParameterBob, clusterParameterName);
+ sp->append(opCtx, &oldClusterParameterBob, clusterParameterName, boost::none);
- setStatus = sp->set(clusterParameterDoc);
+ setStatus = sp->set(clusterParameterDoc, boost::none);
if (!setStatus.isOK()) {
LOGV2_WARNING(6226402,
"Could not set in-memory cluster server parameter",
@@ -155,7 +155,7 @@ Status ClusterServerParameterRefresher::refreshParameters(OperationContext* opCt
}
BSONObjBuilder updatedClusterParameterBob;
- sp->append(opCtx, updatedClusterParameterBob, clusterParameterName);
+ sp->append(opCtx, &updatedClusterParameterBob, clusterParameterName, boost::none);
BSONObj updatedClusterParameterBSON = updatedClusterParameterBob.obj().getOwned();
audit::logUpdateCachedClusterParameter(opCtx->getClient(),
diff --git a/src/mongo/idl/feature_flag.cpp b/src/mongo/idl/feature_flag.cpp
index 93e60479c17..4fbbf8d374c 100644
--- a/src/mongo/idl/feature_flag.cpp
+++ b/src/mongo/idl/feature_flag.cpp
@@ -90,12 +90,13 @@ FeatureFlagServerParameter::FeatureFlagServerParameter(StringData name, FeatureF
: ServerParameter(name, ServerParameterType::kStartupOnly), _storage(storage) {}
void FeatureFlagServerParameter::append(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
bool enabled = _storage.isEnabledAndIgnoreFCV();
{
- auto sub = BSONObjBuilder(b.subobjStart(name));
+ auto sub = BSONObjBuilder(b->subobjStart(name));
sub.append("value"_sd, enabled);
if (enabled) {
@@ -107,13 +108,15 @@ void FeatureFlagServerParameter::append(OperationContext* opCtx,
}
void FeatureFlagServerParameter::appendSupportingRoundtrip(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
bool enabled = _storage.isEnabledAndIgnoreFCV();
- b.append(name, enabled);
+ b->append(name, enabled);
}
-Status FeatureFlagServerParameter::set(const BSONElement& newValueElement) {
+Status FeatureFlagServerParameter::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>&) {
bool newValue;
if (auto status = newValueElement.tryCoerce(&newValue); !status.isOK()) {
@@ -126,7 +129,7 @@ Status FeatureFlagServerParameter::set(const BSONElement& newValueElement) {
return Status::OK();
}
-Status FeatureFlagServerParameter::setFromString(const std::string& str) {
+Status FeatureFlagServerParameter::setFromString(StringData str, const boost::optional<TenantId>&) {
auto swNewValue = idl_server_parameter_detail::coerceFromString<bool>(str);
if (!swNewValue.isOK()) {
return swNewValue.getStatus();
diff --git a/src/mongo/idl/feature_flag.h b/src/mongo/idl/feature_flag.h
index 9f98112eed8..b76f8c6892c 100644
--- a/src/mongo/idl/feature_flag.h
+++ b/src/mongo/idl/feature_flag.h
@@ -102,14 +102,18 @@ public:
* Typically invoked by {getParameter:...} to produce a dictionary
* of ServerParameter settings.
*/
- void append(OperationContext* opCtx, BSONObjBuilder& b, const std::string& name) final;
+ void append(OperationContext* opCtx,
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) final;
/**
* Encode the feature flag value into a BSON object, discarding the version.
*/
void appendSupportingRoundtrip(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) override;
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) override;
/**
* Update the underlying value using a BSONElement
@@ -117,14 +121,14 @@ public:
* Allows setting non-basic values (e.g. vector<string>)
* via the {setParameter: ...} call.
*/
- Status set(const BSONElement& newValueElement) final;
+ Status set(const BSONElement& newValueElement, const boost::optional<TenantId>&) final;
/**
* Update the underlying value from a string.
*
* Typically invoked from commandline --setParameter usage.
*/
- Status setFromString(const std::string& str) final;
+ Status setFromString(StringData str, const boost::optional<TenantId>&) final;
private:
FeatureFlag& _storage;
diff --git a/src/mongo/idl/feature_flag_test.cpp b/src/mongo/idl/feature_flag_test.cpp
index e6e998975c2..1b6be251604 100644
--- a/src/mongo/idl/feature_flag_test.cpp
+++ b/src/mongo/idl/feature_flag_test.cpp
@@ -57,10 +57,10 @@ protected:
void FeatureFlagTest::setUp() {
// Set common flags which test the version string to true
_featureFlagBlender = getServerParameter("featureFlagBlender");
- ASSERT_OK(_featureFlagBlender->setFromString("true"));
+ ASSERT_OK(_featureFlagBlender->setFromString("true", boost::none));
_featureFlagSpoon = getServerParameter("featureFlagSpoon");
- ASSERT_OK(_featureFlagSpoon->setFromString("true"));
+ ASSERT_OK(_featureFlagSpoon->setFromString("true", boost::none));
ASSERT(feature_flags::gFeatureFlagBlender.isEnabledAndIgnoreFCV() == true);
ASSERT(feature_flags::gFeatureFlagSpoon.isEnabledAndIgnoreFCV() == true);
@@ -74,9 +74,9 @@ TEST(IDLFeatureFlag, Basic) {
ASSERT(feature_flags::gFeatureFlagToaster.isEnabledAndIgnoreFCV() == false);
auto* featureFlagToaster = getServerParameter("featureFlagToaster");
- ASSERT_OK(featureFlagToaster->setFromString("true"));
+ ASSERT_OK(featureFlagToaster->setFromString("true", boost::none));
ASSERT(feature_flags::gFeatureFlagToaster.isEnabledAndIgnoreFCV() == true);
- ASSERT_NOT_OK(featureFlagToaster->setFromString("alpha"));
+ ASSERT_NOT_OK(featureFlagToaster->setFromString("alpha", boost::none));
// (Generic FCV reference): feature flag test
ASSERT(feature_flags::gFeatureFlagToaster.getVersion() == multiversion::GenericFCV::kLatest);
@@ -92,9 +92,9 @@ TEST_F(FeatureFlagTest, Version) {
// (Generic FCV reference): feature flag test
ASSERT(feature_flags::gFeatureFlagSpoon.getVersion() == multiversion::GenericFCV::kLastLTS);
- ASSERT_OK(_featureFlagBlender->setFromString("false"));
+ ASSERT_OK(_featureFlagBlender->setFromString("false", boost::none));
ASSERT(feature_flags::gFeatureFlagBlender.isEnabledAndIgnoreFCV() == false);
- ASSERT_NOT_OK(_featureFlagBlender->setFromString("alpha"));
+ ASSERT_NOT_OK(_featureFlagBlender->setFromString("alpha", boost::none));
ASSERT_THROWS(feature_flags::gFeatureFlagBlender.getVersion(), AssertionException);
}
@@ -102,12 +102,12 @@ TEST_F(FeatureFlagTest, Version) {
// Test feature flag server parameters are serialized correctly
TEST_F(FeatureFlagTest, ServerStatus) {
{
- ASSERT_OK(_featureFlagBlender->setFromString("true"));
+ ASSERT_OK(_featureFlagBlender->setFromString("true", boost::none));
ASSERT(feature_flags::gFeatureFlagBlender.isEnabledAndIgnoreFCV() == true);
BSONObjBuilder builder;
- _featureFlagBlender->append(nullptr, builder, "blender");
+ _featureFlagBlender->append(nullptr, &builder, "blender", boost::none);
ASSERT_BSONOBJ_EQ(
builder.obj(),
@@ -118,12 +118,12 @@ TEST_F(FeatureFlagTest, ServerStatus) {
}
{
- ASSERT_OK(_featureFlagBlender->setFromString("false"));
+ ASSERT_OK(_featureFlagBlender->setFromString("false", boost::none));
ASSERT(feature_flags::gFeatureFlagBlender.isEnabledAndIgnoreFCV() == false);
BSONObjBuilder builder;
- _featureFlagBlender->append(nullptr, builder, "blender");
+ _featureFlagBlender->append(nullptr, &builder, "blender", boost::none);
ASSERT_BSONOBJ_EQ(builder.obj(), BSON("blender" << BSON("value" << false)));
}
@@ -155,8 +155,8 @@ TEST_F(FeatureFlagTest, IsEnabledTrue) {
TEST_F(FeatureFlagTest, IsEnabledFalse) {
// Test FCV checks with disabled flag
// Test newest version
- ASSERT_OK(_featureFlagBlender->setFromString("false"));
- ASSERT_OK(_featureFlagSpoon->setFromString("false"));
+ ASSERT_OK(_featureFlagBlender->setFromString("false", boost::none));
+ ASSERT_OK(_featureFlagSpoon->setFromString("false", boost::none));
// (Generic FCV reference): feature flag test
serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest);
@@ -179,7 +179,7 @@ TEST_F(FeatureFlagTest, IsEnabledFalse) {
// Test that the RAIIServerParameterControllerForTest works correctly on a feature flag.
TEST_F(FeatureFlagTest, RAIIFeatureFlagController) {
// Set false feature flag to true
- ASSERT_OK(_featureFlagBlender->setFromString("false"));
+ ASSERT_OK(_featureFlagBlender->setFromString("false", boost::none));
{
RAIIServerParameterControllerForTest controller("featureFlagBlender", true);
ASSERT_TRUE(
@@ -189,7 +189,7 @@ TEST_F(FeatureFlagTest, RAIIFeatureFlagController) {
feature_flags::gFeatureFlagBlender.isEnabled(serverGlobalParams.featureCompatibility));
// Set true feature flag to false
- ASSERT_OK(_featureFlagBlender->setFromString("true"));
+ ASSERT_OK(_featureFlagBlender->setFromString("true", boost::none));
{
RAIIServerParameterControllerForTest controller("featureFlagBlender", false);
ASSERT_FALSE(
diff --git a/src/mongo/idl/server_parameter_specialized_test.cpp b/src/mongo/idl/server_parameter_specialized_test.cpp
index 260afeb2134..a8c2cea06c0 100644
--- a/src/mongo/idl/server_parameter_specialized_test.cpp
+++ b/src/mongo/idl/server_parameter_specialized_test.cpp
@@ -45,7 +45,7 @@ T* getServerParameter(StringData name) {
template <typename Validator>
void ASSERT_APPENDED_VALUE(ServerParameter* sp, Validator validator) {
BSONObjBuilder b;
- sp->append(nullptr, b, sp->name());
+ sp->append(nullptr, &b, sp->name(), boost::none);
auto obj = b.obj();
ASSERT_EQ(obj.nFields(), 1);
@@ -84,23 +84,26 @@ void ASSERT_APPENDED_OBJECT(ServerParameter* sp, const BSONObj& exp) {
// specializedDummy
void SpecializedDummyServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
- b << name << "Dummy Value";
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << "Dummy Value";
}
-Status SpecializedDummyServerParameter::setFromString(const std::string& value) {
+Status SpecializedDummyServerParameter::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
return Status::OK();
}
TEST(SpecializedServerParameter, dummy) {
auto* dsp = getServerParameter("specializedDummy");
ASSERT_APPENDED_STRING(dsp, "Dummy Value");
- ASSERT_OK(dsp->setFromString("new value"));
- ASSERT_NOT_OK(dsp->set(BSON("" << BSON_ARRAY("bar")).firstElement()));
+ ASSERT_OK(dsp->setFromString("new value", boost::none));
+ ASSERT_NOT_OK(dsp->set(BSON("" << BSON_ARRAY("bar")).firstElement(), boost::none));
ASSERT_OK(dsp->set(BSON(""
<< "bar")
- .firstElement()));
+ .firstElement(),
+ boost::none));
}
// specializedWithCtor
@@ -116,20 +119,22 @@ SpecializedConstructorServerParameter::SpecializedConstructorServerParameter(
}
void SpecializedConstructorServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
- b << name << gSCSP;
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << gSCSP;
}
-Status SpecializedConstructorServerParameter::setFromString(const std::string& value) {
- gSCSP = value;
+Status SpecializedConstructorServerParameter::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
+ gSCSP = value.toString();
return Status::OK();
}
TEST(SpecializedServerParameter, withCtor) {
auto* csp = getServerParameter("specializedWithCtor");
ASSERT_APPENDED_STRING(csp, "Value from ctor");
- ASSERT_OK(csp->setFromString("Updated Value"));
+ ASSERT_OK(csp->setFromString("Updated Value", boost::none));
ASSERT_EQ(gSCSP, "Updated Value");
ASSERT_APPENDED_STRING(csp, "Updated Value");
}
@@ -137,12 +142,14 @@ TEST(SpecializedServerParameter, withCtor) {
// specializedWithValue
void SpecializedWithValueServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
- b << name << _data;
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << _data;
}
-Status SpecializedWithValueServerParameter::setFromString(const std::string& value) {
+Status SpecializedWithValueServerParameter::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
return NumberParser{}(value, &_data);
}
@@ -153,7 +160,7 @@ TEST(SpecializedServerParameter, withValue) {
auto* wv = getServerParameter<cls>("specializedWithValue");
ASSERT_EQ(wv->_data, cls::kDataDefault);
ASSERT_APPENDED_INT(wv, cls::kDataDefault);
- ASSERT_OK(wv->setFromString("102"));
+ ASSERT_OK(wv->setFromString("102", boost::none));
ASSERT_APPENDED_INT(wv, 102);
ASSERT_EQ(wv->_data, 102);
}
@@ -161,13 +168,15 @@ TEST(SpecializedServerParameter, withValue) {
// specializedWithStringValue
void SpecializedWithStringValueServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
- b << name << _data;
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << _data;
}
-Status SpecializedWithStringValueServerParameter::setFromString(const std::string& value) {
- _data = value;
+Status SpecializedWithStringValueServerParameter::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
+ _data = value.toString();
return Status::OK();
}
@@ -178,7 +187,7 @@ TEST(SpecializedServerParameter, withStringValue) {
auto* wsv = getServerParameter<cls>("specializedWithStringValue");
ASSERT_EQ(wsv->_data, cls::kDataDefault);
ASSERT_APPENDED_STRING(wsv, cls::kDataDefault);
- ASSERT_OK(wsv->setFromString("Goodbye Land"));
+ ASSERT_OK(wsv->setFromString("Goodbye Land", boost::none));
ASSERT_APPENDED_STRING(wsv, "Goodbye Land");
ASSERT_EQ(wsv->_data, "Goodbye Land");
}
@@ -186,12 +195,14 @@ TEST(SpecializedServerParameter, withStringValue) {
// specializedWithAtomicValue
void SpecializedWithAtomicValueServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
- b << name << _data.load();
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << _data.load();
}
-Status SpecializedWithAtomicValueServerParameter::setFromString(const std::string& value) {
+Status SpecializedWithAtomicValueServerParameter::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
std::uint32_t val;
auto status = NumberParser{}(value, &val);
@@ -210,9 +221,9 @@ TEST(SpecializedServerParameter, withAtomicValue) {
auto* wv = getServerParameter<cls>("specializedWithAtomicValue");
ASSERT_EQ(wv->_data.load(), cls::kDataDefault);
ASSERT_APPENDED_INT(wv, cls::kDataDefault);
- ASSERT_OK(wv->set(BSON("" << 99).firstElement()));
+ ASSERT_OK(wv->set(BSON("" << 99).firstElement(), boost::none));
ASSERT_APPENDED_INT(wv, 99);
- ASSERT_OK(wv->setFromString("101"));
+ ASSERT_OK(wv->setFromString("101", boost::none));
ASSERT_APPENDED_INT(wv, 101);
ASSERT_EQ(wv->_data.load(), 101);
}
@@ -220,12 +231,14 @@ TEST(SpecializedServerParameter, withAtomicValue) {
// specializedWithMultiValue
void SpecializedMultiValueServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
- b << name << BSON("value" << _data.value << "flag" << _data.flag);
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << BSON("value" << _data.value << "flag" << _data.flag);
}
-Status SpecializedMultiValueServerParameter::set(const BSONElement& value) try {
+Status SpecializedMultiValueServerParameter::set(const BSONElement& value,
+ const boost::optional<TenantId>&) try {
auto obj = value.Obj();
_data.value = obj["value"].String();
_data.flag = obj["flag"].Bool();
@@ -234,8 +247,9 @@ Status SpecializedMultiValueServerParameter::set(const BSONElement& value) try {
return {ErrorCodes::BadValue, "Failed parsing extra data"};
}
-Status SpecializedMultiValueServerParameter::setFromString(const std::string& value) {
- return set(BSON("" << BSON("value" << value << "flag" << false)).firstElement());
+Status SpecializedMultiValueServerParameter::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
+ return set(BSON("" << BSON("value" << value << "flag" << false)).firstElement(), boost::none);
}
TEST(SpecializedServerParameter, multiValue) {
@@ -244,7 +258,7 @@ TEST(SpecializedServerParameter, multiValue) {
BSON("value"
<< "start value"
<< "flag" << true));
- ASSERT_OK(edsp->setFromString("second value"));
+ ASSERT_OK(edsp->setFromString("second value", boost::none));
ASSERT_APPENDED_OBJECT(edsp,
BSON("value"
<< "second value"
@@ -252,7 +266,8 @@ TEST(SpecializedServerParameter, multiValue) {
ASSERT_OK(edsp->set(BSON("" << BSON("value"
<< "third value"
<< "flag" << true))
- .firstElement()));
+ .firstElement(),
+ boost::none));
ASSERT_APPENDED_OBJECT(edsp,
BSON("value"
<< "third value"
@@ -266,12 +281,14 @@ SpecializedWithCtorAndValueServerParameter::SpecializedWithCtorAndValueServerPar
: ServerParameter(name, spt) {}
void SpecializedWithCtorAndValueServerParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
- b << name << _data;
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << _data;
}
-Status SpecializedWithCtorAndValueServerParameter::setFromString(const std::string& value) {
+Status SpecializedWithCtorAndValueServerParameter::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
return NumberParser{}(value, &_data);
}
@@ -279,7 +296,7 @@ TEST(SpecializedServerParameter, withCtorAndValue) {
using cls = SpecializedWithCtorAndValueServerParameter;
auto* cvsp = getServerParameter<cls>("specializedWithCtorAndValue");
ASSERT_APPENDED_INT(cvsp, cls::kDataDefault);
- ASSERT_OK(cvsp->setFromString(std::to_string(cls::kDataDefault + 1)));
+ ASSERT_OK(cvsp->setFromString(std::to_string(cls::kDataDefault + 1), boost::none));
ASSERT_EQ(cvsp->_data, cls::kDataDefault + 1);
ASSERT_APPENDED_INT(cvsp, cls::kDataDefault + 1);
}
@@ -290,36 +307,40 @@ namespace {
std::string gSWO = "Initial Value";
} // namespace
-Status SpecializedWithOptions::setFromString(const std::string& value) {
- gSWO = value;
+Status SpecializedWithOptions::setFromString(StringData value, const boost::optional<TenantId>&) {
+ gSWO = value.toString();
return Status::OK();
}
TEST(SpecializedServerParameter, withOptions) {
auto* swo = getServerParameter("specializedWithOptions");
ASSERT_APPENDED_STRING(swo, "###");
- ASSERT_OK(swo->setFromString("second value"));
+ ASSERT_OK(swo->setFromString("second value", boost::none));
ASSERT_EQ(gSWO, "second value");
ASSERT_APPENDED_STRING(swo, "###");
auto* dswo = getServerParameter("deprecatedWithOptions");
ASSERT_APPENDED_STRING(dswo, "###");
- ASSERT_OK(dswo->setFromString("third value"));
+ ASSERT_OK(dswo->setFromString("third value", boost::none));
ASSERT_EQ(gSWO, "third value");
ASSERT_APPENDED_STRING(dswo, "###");
}
// specializedRuntimeOnly
-void SpecializedRuntimeOnly::append(OperationContext*, BSONObjBuilder&, const std::string&) {}
+void SpecializedRuntimeOnly::append(OperationContext*,
+ BSONObjBuilder*,
+ StringData,
+ const boost::optional<TenantId>&) {}
-Status SpecializedRuntimeOnly::setFromString(const std::string& value) {
+Status SpecializedRuntimeOnly::setFromString(StringData value, const boost::optional<TenantId>&) {
return Status::OK();
}
-Status SpecializedRedactedSettable::setFromString(const std::string& value) {
+Status SpecializedRedactedSettable::setFromString(StringData value,
+ const boost::optional<TenantId>&) {
std::cout << "Setting to: " << value << "\n";
- _data = value;
+ _data = value.toString();
return Status::OK();
}
@@ -334,11 +355,11 @@ TEST(SpecializedServerParameter, SpecializedRedactedSettable) {
auto& dataMember = down->_data;
auto store = [&](auto&& name, auto&& value) {
- return sp->set(BSON(name << value).firstElement());
+ return sp->set(BSON(name << value).firstElement(), boost::none);
};
auto load = [&] {
BSONObjBuilder bob;
- sp->append(nullptr, bob, sp->name());
+ sp->append(nullptr, &bob, sp->name(), boost::none);
return bob.obj();
};
@@ -389,14 +410,17 @@ TEST(SpecializedServerParameter, withScope) {
// specializedWithValidateServerParameter
void SpecializedWithValidateServerParameter::append(OperationContext*,
- BSONObjBuilder&,
- const std::string&) {}
+ BSONObjBuilder*,
+ StringData,
+ const boost::optional<TenantId>&) {}
-Status SpecializedWithValidateServerParameter::setFromString(const std::string& str) {
+Status SpecializedWithValidateServerParameter::setFromString(StringData str,
+ const boost::optional<TenantId>&) {
return NumberParser{}(str, &_data);
}
-Status SpecializedWithValidateServerParameter::validate(const BSONElement& newValueElement) const {
+Status SpecializedWithValidateServerParameter::validate(
+ const BSONElement& newValueElement, const boost::optional<TenantId>& tenantId) const {
try {
auto val = newValueElement.Int();
if (val < 0) {
@@ -418,27 +442,33 @@ TEST(SpecializedServerParameter, withValidate) {
ASSERT(nullptr != validateSP);
// Assert that validate works by itself.
- ASSERT_OK(validateSP->validate(BSON(kSpecializedWithValidate << 5).firstElement()));
- ASSERT_OK(validateSP->validate(BSON(kSpecializedWithValidate << 0).firstElement()));
- ASSERT_NOT_OK(validateSP->validate(BSON(kSpecializedWithValidate << -1).firstElement()));
+ ASSERT_OK(
+ validateSP->validate(BSON(kSpecializedWithValidate << 5).firstElement(), boost::none));
+ ASSERT_OK(
+ validateSP->validate(BSON(kSpecializedWithValidate << 0).firstElement(), boost::none));
+ ASSERT_NOT_OK(
+ validateSP->validate(BSON(kSpecializedWithValidate << -1).firstElement(), boost::none));
// Assert that validate works when called within set.
- ASSERT_OK(validateSP->set(BSON(kSpecializedWithValidate << 5).firstElement()));
- ASSERT_OK(validateSP->set(BSON(kSpecializedWithValidate << 0).firstElement()));
- ASSERT_NOT_OK(validateSP->set(BSON(kSpecializedWithValidate << -1).firstElement()));
+ ASSERT_OK(validateSP->set(BSON(kSpecializedWithValidate << 5).firstElement(), boost::none));
+ ASSERT_OK(validateSP->set(BSON(kSpecializedWithValidate << 0).firstElement(), boost::none));
+ ASSERT_NOT_OK(
+ validateSP->set(BSON(kSpecializedWithValidate << -1).firstElement(), boost::none));
}
// specializedWithClusterServerParameter
void SpecializedClusterServerParameter::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& name) {
- builder.append("_id"_sd, name);
- builder.appendElementsUnique(_data.toBSON());
+ BSONObjBuilder* builder,
+ StringData name,
+ const boost::optional<TenantId>& tenantId) {
+ builder->append("_id"_sd, name);
+ builder->appendElementsUnique(_data.toBSON());
}
-Status SpecializedClusterServerParameter::set(const BSONElement& newValueElement) {
- Status status = validate(newValueElement);
+Status SpecializedClusterServerParameter::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>& tenantId) {
+ Status status = validate(newValueElement, tenantId);
if (!status.isOK()) {
return status;
}
@@ -447,7 +477,8 @@ Status SpecializedClusterServerParameter::set(const BSONElement& newValueElement
return Status::OK();
}
-Status SpecializedClusterServerParameter::validate(const BSONElement& newValueElement) const {
+Status SpecializedClusterServerParameter::validate(
+ const BSONElement& newValueElement, const boost::optional<TenantId>& tenantId) const {
try {
auto obj = newValueElement.Obj();
auto strValue = obj["strData"_sd].String();
@@ -464,12 +495,13 @@ Status SpecializedClusterServerParameter::validate(const BSONElement& newValueEl
return Status::OK();
}
-Status SpecializedClusterServerParameter::reset() {
+Status SpecializedClusterServerParameter::reset(const boost::optional<TenantId>& tenantId) {
_data.reset();
return Status::OK();
}
-LogicalTime SpecializedClusterServerParameter::getClusterParameterTime() const {
+LogicalTime SpecializedClusterServerParameter::getClusterParameterTime(
+ const boost::optional<TenantId>& tenantId) const {
return _data.getClusterParameterTime();
}
@@ -489,17 +521,17 @@ TEST(SpecializedServerParameter, clusterServerParameter) {
data.setStrData("hello");
data.setId(kSpecializedCSPName);
data.serialize(&builder);
- ASSERT_OK(specializedCsp->set(builder.asTempObj()));
+ ASSERT_OK(specializedCsp->set(builder.asTempObj(), boost::none));
// Assert that the parameter cannot be set from strings.
- ASSERT_NOT_OK(specializedCsp->setFromString(""));
+ ASSERT_NOT_OK(specializedCsp->setFromString("", boost::none));
// Assert that the clusterParameterTime can be retrieved.
- ASSERT_EQ(specializedCsp->getClusterParameterTime(), updateTime);
+ ASSERT_EQ(specializedCsp->getClusterParameterTime(boost::none), updateTime);
// Assert that the parameter can be appended to a builder.
builder.resetToEmpty();
- specializedCsp->append(nullptr, builder, kSpecializedCSPName.toString());
+ specializedCsp->append(nullptr, &builder, kSpecializedCSPName.toString(), boost::none);
auto obj = builder.asTempObj();
ASSERT_EQ(obj.nFields(), 4);
ASSERT_EQ(obj["_id"_sd].String(), kSpecializedCSPName);
@@ -514,13 +546,13 @@ TEST(SpecializedServerParameter, clusterServerParameter) {
data.setIntData(-1);
data.setStrData("");
data.serialize(&builder);
- ASSERT_NOT_OK(specializedCsp->validate(builder.asTempObj()));
- ASSERT_NOT_OK(specializedCsp->set(builder.asTempObj()));
+ ASSERT_NOT_OK(specializedCsp->validate(builder.asTempObj(), boost::none));
+ ASSERT_NOT_OK(specializedCsp->set(builder.asTempObj(), boost::none));
// Assert that the parameter can be reset to its defaults.
builder.resetToEmpty();
- ASSERT_OK(specializedCsp->reset());
- specializedCsp->append(nullptr, builder, kSpecializedCSPName.toString());
+ ASSERT_OK(specializedCsp->reset(boost::none));
+ specializedCsp->append(nullptr, &builder, kSpecializedCSPName.toString(), boost::none);
obj = builder.asTempObj();
ASSERT_EQ(obj.nFields(), 4);
ASSERT_EQ(obj["_id"_sd].String(), kSpecializedCSPName);
diff --git a/src/mongo/idl/server_parameter_test_util.h b/src/mongo/idl/server_parameter_test_util.h
index 46c4060f028..a916208d948 100644
--- a/src/mongo/idl/server_parameter_test_util.h
+++ b/src/mongo/idl/server_parameter_test_util.h
@@ -49,11 +49,11 @@ public:
: _serverParam(ServerParameterSet::getNodeParameterSet()->get(name)) {
// Save the old value
BSONObjBuilder bob;
- _serverParam->appendSupportingRoundtrip(nullptr, bob, name);
+ _serverParam->appendSupportingRoundtrip(nullptr, &bob, name, boost::none);
_oldValue = bob.obj();
// Set to the new value
- uassertStatusOK(_serverParam->set(BSON(name << value).firstElement()));
+ uassertStatusOK(_serverParam->set(BSON(name << value).firstElement(), boost::none));
}
/**
@@ -62,7 +62,7 @@ public:
~RAIIServerParameterControllerForTest() {
// Reset to the old value
auto elem = _oldValue.firstElement();
- uassertStatusOK(_serverParam->set(elem));
+ uassertStatusOK(_serverParam->set(elem, boost::none));
}
private:
diff --git a/src/mongo/idl/server_parameter_with_storage_test.cpp b/src/mongo/idl/server_parameter_with_storage_test.cpp
index 669d6e9b907..b9a22ed689b 100644
--- a/src/mongo/idl/server_parameter_with_storage_test.cpp
+++ b/src/mongo/idl/server_parameter_with_storage_test.cpp
@@ -67,21 +67,21 @@ void doStorageTest(StringData name,
uassertStatusOK(idl_server_parameter_detail::coerceFromString<element_type>(v));
// setFromString() API.
- ASSERT_OK(param.setFromString(v));
- ASSERT_EQ_OR_NAN(param.getValue(), typedVal);
+ ASSERT_OK(param.setFromString(v, boost::none));
+ ASSERT_EQ_OR_NAN(param.getValue(boost::none), typedVal);
// set() API.
- ASSERT_OK(param.set(BSON("" << typedVal).firstElement()));
+ ASSERT_OK(param.set(BSON("" << typedVal).firstElement(), boost::none));
// append() API.
BSONObjBuilder b;
element_type exp;
- param.append(nullptr, b, name.toString());
+ param.append(nullptr, &b, name.toString(), boost::none);
ASSERT(b.obj().firstElement().coerce(&exp));
- ASSERT_EQ_OR_NAN(param.getValue(), exp);
+ ASSERT_EQ_OR_NAN(param.getValue(boost::none), exp);
}
for (const auto& v : invalid) {
- ASSERT_NOT_OK(param.setFromString(v));
+ ASSERT_NOT_OK(param.setFromString(v, boost::none));
ASSERT_NOT_OK(idl_server_parameter_detail::coerceFromString<element_type>(v));
}
@@ -93,7 +93,7 @@ void doStorageTest(StringData name,
});
for (size_t i = 0; i < valid.size(); ++i) {
ASSERT_EQ(count, i);
- ASSERT_OK(param.setFromString(valid[i]));
+ ASSERT_OK(param.setFromString(valid[i], boost::none));
}
ASSERT_EQ(count, valid.size());
@@ -102,20 +102,22 @@ void doStorageTest(StringData name,
for (const auto& v : valid) {
auto typedVal =
uassertStatusOK(idl_server_parameter_detail::coerceFromString<element_type>(v));
- ASSERT_NOT_OK(param.setFromString(v));
- ASSERT_EQ_OR_NAN(param.getValue(), typedVal);
+ ASSERT_NOT_OK(param.setFromString(v, boost::none));
+ ASSERT_EQ_OR_NAN(param.getValue(boost::none), typedVal);
}
// Clear onUpdate for next test.
param.setOnUpdate(nullptr);
- ASSERT_OK(param.setFromString(valid[0]));
+ ASSERT_OK(param.setFromString(valid[0], boost::none));
// Check validation occurs and DOES block value being set.
- auto current = param.getValue();
- param.addValidator([](const element_type&) { return Status(ErrorCodes::BadValue, "Go away"); });
+ auto current = param.getValue(boost::none);
+ param.addValidator([](const element_type&, const boost::optional<TenantId>&) {
+ return Status(ErrorCodes::BadValue, "Go away");
+ });
for (const auto& v : valid) {
- ASSERT_NOT_OK(param.setFromString(v));
- ASSERT_EQ_OR_NAN(current, param.getValue());
+ ASSERT_NOT_OK(param.setFromString(v, boost::none));
+ ASSERT_EQ_OR_NAN(current, param.getValue(boost::none));
}
}
@@ -165,14 +167,14 @@ TEST(ServerParameterWithStorage, BoundsTest) {
IDLServerParameterWithStorage<SPT::kStartupOnly, int> param("BoundsTest", val);
param.addBound<GT>(10);
- auto status = param.setFromString("5");
+ auto status = param.setFromString("5", boost::none);
ASSERT_NOT_OK(status);
ASSERT_EQ(status.reason(), "Invalid value for parameter BoundsTest: 5 is not greater than 10");
- ASSERT_OK(param.setFromString("15"));
+ ASSERT_OK(param.setFromString("15", boost::none));
param.addBound<LT>(20);
- ASSERT_OK(param.setValue(15));
- status = param.setValue(25);
+ ASSERT_OK(param.setValue(15, boost::none));
+ status = param.setValue(25, boost::none);
ASSERT_NOT_OK(status);
ASSERT_EQ(status.reason(), "Invalid value for parameter BoundsTest: 25 is not less than 20");
}
@@ -190,14 +192,14 @@ TEST(IDLServerParameterWithStorage, stdIntDeclared) {
ASSERT_EQ(test::gStdIntDeclared.load(), 42);
auto* stdIntDeclared = getNodeServerParameter("stdIntDeclared");
- ASSERT_OK(stdIntDeclared->setFromString("999"));
+ ASSERT_OK(stdIntDeclared->setFromString("999", boost::none));
ASSERT_EQ(test::gStdIntDeclared.load(), 999);
- ASSERT_NOT_OK(stdIntDeclared->setFromString("1000"));
- ASSERT_NOT_OK(stdIntDeclared->setFromString("-1"));
- ASSERT_NOT_OK(stdIntDeclared->setFromString("alpha"));
+ ASSERT_NOT_OK(stdIntDeclared->setFromString("1000", boost::none));
+ ASSERT_NOT_OK(stdIntDeclared->setFromString("-1", boost::none));
+ ASSERT_NOT_OK(stdIntDeclared->setFromString("alpha", boost::none));
// Reset to default.
- ASSERT_OK(stdIntDeclared->reset());
+ ASSERT_OK(stdIntDeclared->reset(boost::none));
ASSERT_EQ(test::gStdIntDeclared.load(), 42);
}
@@ -208,17 +210,17 @@ TEST(IDLServerParameterWithStorage, stdIntPreallocated) {
ASSERT_EQ(test::gStdIntPreallocatedUpdateCount.load(), 1);
auto* stdIntPreallocated = getNodeServerParameter("stdIntPreallocated");
- ASSERT_OK(stdIntPreallocated->setFromString("41"));
+ ASSERT_OK(stdIntPreallocated->setFromString("41", boost::none));
ASSERT_EQ(test::gStdIntPreallocated.load(), 41);
ASSERT_EQ(test::gStdIntPreallocatedUpdateCount.load(), 2);
- ASSERT_NOT_OK(stdIntPreallocated->setFromString("42"));
- ASSERT_NOT_OK(stdIntPreallocated->setFromString("-1"));
- ASSERT_NOT_OK(stdIntPreallocated->setFromString("alpha"));
+ ASSERT_NOT_OK(stdIntPreallocated->setFromString("42", boost::none));
+ ASSERT_NOT_OK(stdIntPreallocated->setFromString("-1", boost::none));
+ ASSERT_NOT_OK(stdIntPreallocated->setFromString("alpha", boost::none));
ASSERT_EQ(test::gStdIntPreallocatedUpdateCount.load(), 2);
// Reset to default.
- ASSERT_OK(stdIntPreallocated->reset());
+ ASSERT_OK(stdIntPreallocated->reset(boost::none));
ASSERT_EQ(test::gStdIntPreallocated.load(), 11);
ASSERT_EQ(test::gStdIntPreallocatedUpdateCount.load(), 3);
}
@@ -227,11 +229,11 @@ TEST(IDLServerParameterWithStorage, startupString) {
auto* sp = getNodeServerParameter("startupString");
ASSERT_EQ(sp->allowedToChangeAtStartup(), true);
ASSERT_EQ(sp->allowedToChangeAtRuntime(), false);
- ASSERT_OK(sp->setFromString("New Value"));
+ ASSERT_OK(sp->setFromString("New Value", boost::none));
ASSERT_EQ(test::gStartupString, "New Value");
// Reset to default.
- ASSERT_OK(sp->reset());
+ ASSERT_OK(sp->reset(boost::none));
ASSERT_EQ(test::gStartupString, "");
}
@@ -239,27 +241,27 @@ TEST(IDLServerParameterWithStorage, runtimeBoostDouble) {
auto* sp = getNodeServerParameter("runtimeBoostDouble");
ASSERT_EQ(sp->allowedToChangeAtStartup(), false);
ASSERT_EQ(sp->allowedToChangeAtRuntime(), true);
- ASSERT_OK(sp->setFromString("1.0"));
+ ASSERT_OK(sp->setFromString("1.0", boost::none));
ASSERT_EQ(test::gRuntimeBoostDouble.get(), 1.0);
// Reset to default.
- ASSERT_OK(sp->reset());
+ ASSERT_OK(sp->reset(boost::none));
ASSERT_EQ(test::gRuntimeBoostDouble.get(), 0.0);
}
TEST(IDLServerParameterWithStorage, startupStringRedacted) {
auto* sp = getNodeServerParameter("startupStringRedacted");
- ASSERT_OK(sp->setFromString("Hello World"));
+ ASSERT_OK(sp->setFromString("Hello World", boost::none));
ASSERT_EQ(test::gStartupStringRedacted, "Hello World");
BSONObjBuilder b;
- sp->append(nullptr, b, sp->name());
+ sp->append(nullptr, &b, sp->name(), boost::none);
auto obj = b.obj();
ASSERT_EQ(obj.nFields(), 1);
ASSERT_EQ(obj[sp->name()].String(), "###");
// Reset to default.
- ASSERT_OK(sp->reset());
+ ASSERT_OK(sp->reset(boost::none));
ASSERT_EQ(test::gStartupStringRedacted, "");
}
@@ -268,12 +270,12 @@ TEST(IDLServerParameterWithStorage, startupIntWithExpressions) {
getNodeServerParameter("startupIntWithExpressions"));
ASSERT_EQ(test::gStartupIntWithExpressions, test::kStartupIntWithExpressionsDefault);
- ASSERT_NOT_OK(sp->setValue(test::kStartupIntWithExpressionsMinimum - 1));
- ASSERT_OK(sp->setValue(test::kStartupIntWithExpressionsMinimum));
+ ASSERT_NOT_OK(sp->setValue(test::kStartupIntWithExpressionsMinimum - 1, boost::none));
+ ASSERT_OK(sp->setValue(test::kStartupIntWithExpressionsMinimum, boost::none));
ASSERT_EQ(test::gStartupIntWithExpressions, test::kStartupIntWithExpressionsMinimum);
- ASSERT_NOT_OK(sp->setValue(test::kStartupIntWithExpressionsMaximum + 1));
- ASSERT_OK(sp->setValue(test::kStartupIntWithExpressionsMaximum));
+ ASSERT_NOT_OK(sp->setValue(test::kStartupIntWithExpressionsMaximum + 1, boost::none));
+ ASSERT_OK(sp->setValue(test::kStartupIntWithExpressionsMaximum, boost::none));
ASSERT_EQ(test::gStartupIntWithExpressions, test::kStartupIntWithExpressionsMaximum);
}
@@ -288,7 +290,7 @@ TEST(IDLServerParameterWithStorage, exportedDefaults) {
TEST(IDLServerParameterWithStorage, RAIIServerParameterController) {
// Test int
auto* stdIntDeclared = getNodeServerParameter("stdIntDeclared");
- ASSERT_OK(stdIntDeclared->setFromString("42"));
+ ASSERT_OK(stdIntDeclared->setFromString("42", boost::none));
ASSERT_EQ(test::gStdIntDeclared.load(), 42);
{
RAIIServerParameterControllerForTest controller("stdIntDeclared", 10);
@@ -298,7 +300,7 @@ TEST(IDLServerParameterWithStorage, RAIIServerParameterController) {
// Test bool
auto* uglyComplicated = getNodeServerParameter("ugly complicated-name.sp");
- ASSERT_OK(uglyComplicated->setFromString("false"));
+ ASSERT_OK(uglyComplicated->setFromString("false", boost::none));
ASSERT_EQ(test::gUglyComplicatedNameSp, false);
{
RAIIServerParameterControllerForTest controller("ugly complicated-name.sp", true);
@@ -309,7 +311,7 @@ TEST(IDLServerParameterWithStorage, RAIIServerParameterController) {
// Test string
auto* startupString = getNodeServerParameter("startupString");
const auto coolStartupString = "Cool startup string";
- ASSERT_OK(startupString->setFromString(coolStartupString));
+ ASSERT_OK(startupString->setFromString(coolStartupString, boost::none));
ASSERT_EQ(test::gStartupString, coolStartupString);
{
const auto badStartupString = "Bad startup string";
@@ -330,10 +332,10 @@ TEST(IDLServerParameterWithStorage, CSPStorageTest) {
getClusterServerParameter("changeStreamOptions"));
// Check that current value is the default value.
- test::ChangeStreamOptionsClusterParam retrievedParam = clusterParam->getValue();
+ test::ChangeStreamOptionsClusterParam retrievedParam = clusterParam->getValue(boost::none);
ASSERT_EQ(retrievedParam.getPreAndPostImages().getExpireAfterSeconds(), 30);
ASSERT_EQ(retrievedParam.getTestStringField(), "");
- ASSERT_EQ(clusterParam->getClusterParameterTime(), LogicalTime::kUninitialized);
+ ASSERT_EQ(clusterParam->getClusterParameterTime(boost::none), LogicalTime::kUninitialized);
// Set to new value and check that the updated value is seen on get.
test::ChangeStreamOptionsClusterParam updatedParam;
@@ -348,18 +350,18 @@ TEST(IDLServerParameterWithStorage, CSPStorageTest) {
updatedParam.setClusterServerParameter(baseCSP);
updatedParam.setPreAndPostImages(updatedPrePostImgs);
updatedParam.setTestStringField("testString");
- ASSERT_OK(clusterParam->ServerParameter::set(updatedParam.toBSON()));
+ ASSERT_OK(clusterParam->ServerParameter::set(updatedParam.toBSON(), boost::none));
- retrievedParam = clusterParam->getValue();
+ retrievedParam = clusterParam->getValue(boost::none);
ASSERT_EQ(retrievedParam.getPreAndPostImages().getExpireAfterSeconds(), 40);
ASSERT_EQ(retrievedParam.getTestStringField(), "testString");
ASSERT_EQ(retrievedParam.getClusterParameterTime(), updateTime);
- ASSERT_EQ(clusterParam->getClusterParameterTime(), updateTime);
+ ASSERT_EQ(clusterParam->getClusterParameterTime(boost::none), updateTime);
ASSERT_EQ(test::count, 1);
// Append to BSONObj and verify that expected fields are present.
BSONObjBuilder b;
- clusterParam->append(nullptr, b, clusterParam->name());
+ clusterParam->append(nullptr, &b, clusterParam->name(), boost::none);
auto obj = b.obj();
ASSERT_EQ(obj.nFields(), 4);
ASSERT_EQ(obj["_id"_sd].String(), "changeStreamOptions");
@@ -368,15 +370,15 @@ TEST(IDLServerParameterWithStorage, CSPStorageTest) {
ASSERT_EQ(obj["clusterParameterTime"_sd].timestamp(), updateTime.asTimestamp());
// setFromString should fail for cluster server parameters.
- ASSERT_NOT_OK(clusterParam->setFromString(""));
+ ASSERT_NOT_OK(clusterParam->setFromString("", boost::none));
// Reset the parameter and check that it now has its default value.
- ASSERT_OK(clusterParam->reset());
- retrievedParam = clusterParam->getValue();
+ ASSERT_OK(clusterParam->reset(boost::none));
+ retrievedParam = clusterParam->getValue(boost::none);
ASSERT_EQ(retrievedParam.getPreAndPostImages().getExpireAfterSeconds(), 30);
ASSERT_EQ(retrievedParam.getTestStringField(), "");
ASSERT_EQ(retrievedParam.getClusterParameterTime(), LogicalTime::kUninitialized);
- ASSERT_EQ(clusterParam->getClusterParameterTime(), LogicalTime::kUninitialized);
+ ASSERT_EQ(clusterParam->getClusterParameterTime(boost::none), LogicalTime::kUninitialized);
ASSERT_EQ(test::count, 2);
// Update the default value. The parameter should automatically reset to the new default value.
@@ -387,11 +389,11 @@ TEST(IDLServerParameterWithStorage, CSPStorageTest) {
newDefaultParam.setPreAndPostImages(newDefaultPrePostImgs);
newDefaultParam.setTestStringField("default");
ASSERT_OK(clusterParam->setDefault(newDefaultParam));
- retrievedParam = clusterParam->getValue();
+ retrievedParam = clusterParam->getValue(boost::none);
ASSERT_EQ(retrievedParam.getPreAndPostImages().getExpireAfterSeconds(), 35);
ASSERT_EQ(retrievedParam.getTestStringField(), "default");
ASSERT_EQ(retrievedParam.getClusterParameterTime(), LogicalTime::kUninitialized);
- ASSERT_EQ(clusterParam->getClusterParameterTime(), LogicalTime::kUninitialized);
+ ASSERT_EQ(clusterParam->getClusterParameterTime(boost::none), LogicalTime::kUninitialized);
ASSERT_EQ(test::count, 3);
// Updating the default value a second time should have no effect.
@@ -399,7 +401,7 @@ TEST(IDLServerParameterWithStorage, CSPStorageTest) {
newDefaultParam.setPreAndPostImages(newDefaultPrePostImgs);
newDefaultParam.setTestStringField("newDefault");
ASSERT_OK(clusterParam->setDefault(newDefaultParam));
- retrievedParam = clusterParam->getValue();
+ retrievedParam = clusterParam->getValue(boost::none);
ASSERT_EQ(retrievedParam.getPreAndPostImages().getExpireAfterSeconds(), 35);
ASSERT_EQ(retrievedParam.getTestStringField(), "default");
ASSERT_EQ(test::count, 3);
@@ -408,12 +410,12 @@ TEST(IDLServerParameterWithStorage, CSPStorageTest) {
updatedParam.setPreAndPostImages(updatedPrePostImgs);
updatedParam.setTestStringField("newTestString");
updateTime = LogicalTime(Timestamp(Date_t::now()));
- ASSERT_NOT_OK(clusterParam->ServerParameter::validate(updatedParam.toBSON()));
- ASSERT_NOT_OK(clusterParam->ServerParameter::set(updatedParam.toBSON()));
- retrievedParam = clusterParam->getValue();
+ ASSERT_NOT_OK(clusterParam->ServerParameter::validate(updatedParam.toBSON(), boost::none));
+ ASSERT_NOT_OK(clusterParam->ServerParameter::set(updatedParam.toBSON(), boost::none));
+ retrievedParam = clusterParam->getValue(boost::none);
ASSERT_EQ(retrievedParam.getPreAndPostImages().getExpireAfterSeconds(), 35);
ASSERT_EQ(retrievedParam.getTestStringField(), "default");
- ASSERT_EQ(clusterParam->getClusterParameterTime(), LogicalTime::kUninitialized);
+ ASSERT_EQ(clusterParam->getClusterParameterTime(boost::none), LogicalTime::kUninitialized);
ASSERT_EQ(test::count, 3);
}
diff --git a/src/mongo/idl/server_parameter_with_storage_test.h b/src/mongo/idl/server_parameter_with_storage_test.h
index fe6730b8da7..98c04d95c71 100644
--- a/src/mongo/idl/server_parameter_with_storage_test.h
+++ b/src/mongo/idl/server_parameter_with_storage_test.h
@@ -56,10 +56,15 @@ inline Status validateOdd(const std::int32_t& value) {
return (value & 1) ? Status::OK() : Status(ErrorCodes::BadValue, "Must be odd");
}
+inline Status validateOddSP(const std::int32_t& value, const boost::optional<TenantId>&) {
+ return validateOdd(value);
+}
+
/**
* Validates that the new expireAfterSeconds is non-negative.
*/
-inline Status validateNonNegativeExpireAfterSeconds(const ChangeStreamOptionsClusterParam& newVal) {
+inline Status validateNonNegativeExpireAfterSeconds(const ChangeStreamOptionsClusterParam& newVal,
+ const boost::optional<TenantId>& tenantId) {
if (newVal.getPreAndPostImages().getExpireAfterSeconds() < 0) {
return Status(ErrorCodes::BadValue, "Should be non-negative value only");
}
diff --git a/src/mongo/idl/server_parameter_with_storage_test.idl b/src/mongo/idl/server_parameter_with_storage_test.idl
index c34eb3a8c21..575bf92cd78 100644
--- a/src/mongo/idl/server_parameter_with_storage_test.idl
+++ b/src/mongo/idl/server_parameter_with_storage_test.idl
@@ -42,7 +42,7 @@ server_parameters:
cpp_varname: gStdIntPreallocated
default: 11
validator:
- callback: "validateOdd"
+ callback: "validateOddSP"
gt: 0
on_update: "onUpdateStdIntPreallocated"
diff --git a/src/mongo/logv2/logv2_options.cpp b/src/mongo/logv2/logv2_options.cpp
index 44cab60c1ff..7d5cc14eea7 100644
--- a/src/mongo/logv2/logv2_options.cpp
+++ b/src/mongo/logv2/logv2_options.cpp
@@ -42,12 +42,14 @@
namespace mongo {
void RedactEncryptedFields::append(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {
- b << name << logv2::shouldRedactBinDataEncrypt();
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << logv2::shouldRedactBinDataEncrypt();
}
-Status RedactEncryptedFields::set(const BSONElement& newValueElement) {
+Status RedactEncryptedFields::set(const BSONElement& newValueElement,
+ const boost::optional<TenantId>&) {
bool newVal;
if (!newValueElement.coerce(&newVal)) {
return {ErrorCodes::BadValue,
@@ -58,7 +60,7 @@ Status RedactEncryptedFields::set(const BSONElement& newValueElement) {
return Status::OK();
}
-Status RedactEncryptedFields::setFromString(const std::string& str) {
+Status RedactEncryptedFields::setFromString(StringData str, const boost::optional<TenantId>&) {
if (str == "true" || str == "1") {
logv2::setShouldRedactBinDataEncrypt(true);
} else if (str == "false" || str == "0") {
diff --git a/src/mongo/s/commands/cluster_hello_cmd.cpp b/src/mongo/s/commands/cluster_hello_cmd.cpp
index e1b01eed58b..005a6e2ec26 100644
--- a/src/mongo/s/commands/cluster_hello_cmd.cpp
+++ b/src/mongo/s/commands/cluster_hello_cmd.cpp
@@ -218,7 +218,7 @@ public:
if (auto sp = ServerParameterSet::getNodeParameterSet()->getIfExists(
kAutomationServiceDescriptorFieldName)) {
- sp->append(opCtx, result, kAutomationServiceDescriptorFieldName);
+ sp->append(opCtx, &result, kAutomationServiceDescriptorFieldName, boost::none);
}
MessageCompressorManager::forSession(opCtx->getClient()->session())
diff --git a/src/mongo/s/hedge_options_util_test.cpp b/src/mongo/s/hedge_options_util_test.cpp
index b7736b4ad16..e1093dfa66f 100644
--- a/src/mongo/s/hedge_options_util_test.cpp
+++ b/src/mongo/s/hedge_options_util_test.cpp
@@ -54,7 +54,7 @@ protected:
BSONObjIterator parameterIterator(parameters);
while (parameterIterator.more()) {
BSONElement parameter = parameterIterator.next();
- uassertStatusOK(paramSet->get(parameter.fieldName())->set(parameter));
+ uassertStatusOK(paramSet->get(parameter.fieldName())->set(parameter, boost::none));
}
}
diff --git a/src/mongo/s/mongos_server_parameters.cpp b/src/mongo/s/mongos_server_parameters.cpp
index 8adb722635b..bb31d272b5f 100644
--- a/src/mongo/s/mongos_server_parameters.cpp
+++ b/src/mongo/s/mongos_server_parameters.cpp
@@ -44,12 +44,14 @@ std::string toReadHedgingModeString(ReadHedgingMode readHedgingMode) {
AtomicWord<ReadHedgingMode> gReadHedgingMode{ReadHedgingMode::kOn};
void HedgingModeServerParameter::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& name) {
- builder.append(name, toReadHedgingModeString(gReadHedgingMode.load()));
+ BSONObjBuilder* builder,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ builder->append(name, toReadHedgingModeString(gReadHedgingMode.load()));
}
-Status HedgingModeServerParameter::setFromString(const std::string& modeStr) {
+Status HedgingModeServerParameter::setFromString(StringData modeStr,
+ const boost::optional<TenantId>&) {
if (modeStr == "on") {
gReadHedgingMode.store(ReadHedgingMode::kOn);
} else if (modeStr == "off") {
diff --git a/src/mongo/s/sharding_task_executor_pool_controller.cpp b/src/mongo/s/sharding_task_executor_pool_controller.cpp
index bd2313125a8..4b416d86f05 100644
--- a/src/mongo/s/sharding_task_executor_pool_controller.cpp
+++ b/src/mongo/s/sharding_task_executor_pool_controller.cpp
@@ -64,7 +64,8 @@ bool isConfigServer(const ShardRegistry* sr, const HostAndPort& peer) {
} // namespace
-Status ShardingTaskExecutorPoolController::validateHostTimeout(const int& hostTimeoutMS) {
+Status ShardingTaskExecutorPoolController::validateHostTimeout(const int& hostTimeoutMS,
+ const boost::optional<TenantId>&) {
auto toRefreshTimeoutMS = gParameters.toRefreshTimeoutMS.load();
auto pendingTimeoutMS = gParameters.pendingTimeoutMS.load();
if (hostTimeoutMS >= (toRefreshTimeoutMS + pendingTimeoutMS)) {
@@ -78,7 +79,8 @@ Status ShardingTaskExecutorPoolController::validateHostTimeout(const int& hostTi
return Status(ErrorCodes::BadValue, msg);
}
-Status ShardingTaskExecutorPoolController::validatePendingTimeout(const int& pendingTimeoutMS) {
+Status ShardingTaskExecutorPoolController::validatePendingTimeout(
+ const int& pendingTimeoutMS, const boost::optional<TenantId>&) {
auto toRefreshTimeoutMS = gParameters.toRefreshTimeoutMS.load();
if (pendingTimeoutMS < toRefreshTimeoutMS) {
return Status::OK();
diff --git a/src/mongo/s/sharding_task_executor_pool_controller.h b/src/mongo/s/sharding_task_executor_pool_controller.h
index 9ef7c6bfd6c..353da591ab6 100644
--- a/src/mongo/s/sharding_task_executor_pool_controller.h
+++ b/src/mongo/s/sharding_task_executor_pool_controller.h
@@ -115,12 +115,13 @@ public:
* Validate that hostTimeoutMS is greater than the sum of pendingTimeoutMS and
* toRefreshTimeoutMS
*/
- static Status validateHostTimeout(const int& hostTimeoutMS);
+ static Status validateHostTimeout(const int& hostTimeoutMS, const boost::optional<TenantId>&);
/**
* Validate that pendingTimeoutMS is less than toRefreshTimeoutMS
*/
- static Status validatePendingTimeout(const int& pendingTimeoutMS);
+ static Status validatePendingTimeout(const int& pendingTimeoutMS,
+ const boost::optional<TenantId>&);
/**
* Matches the matching strategy string against a set of literals
diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp
index 48b1d9fdf71..e23f89ff7dc 100644
--- a/src/mongo/shell/shell_options.cpp
+++ b/src/mongo/shell/shell_options.cpp
@@ -322,7 +322,7 @@ Status storeMongoShellOptions(const moe::Environment& params,
str::stream()
<< "Cannot use --setShellParameter to set '" << name << "' at startup"};
}
- auto status = param->setFromString(it.second);
+ auto status = param->setFromString(it.second, boost::none);
if (!status.isOK()) {
return {ErrorCodes::BadValue,
str::stream()
diff --git a/src/mongo/util/fail_point.cpp b/src/mongo/util/fail_point.cpp
index 57e7276919f..cfb80b68b17 100644
--- a/src/mongo/util/fail_point.cpp
+++ b/src/mongo/util/fail_point.cpp
@@ -360,12 +360,13 @@ FailPointServerParameter::FailPointServerParameter(StringData name, ServerParame
}
void FailPointServerParameter::append(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {
- b << name << _data->toBSON();
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
+ *b << name << _data->toBSON();
}
-Status FailPointServerParameter::setFromString(const std::string& str) {
+Status FailPointServerParameter::setFromString(StringData str, const boost::optional<TenantId>&) {
BSONObj failPointOptions;
try {
failPointOptions = fromjson(str);
diff --git a/src/mongo/util/net/ssl_manager.cpp b/src/mongo/util/net/ssl_manager.cpp
index 08c97811d08..6cd55213043 100644
--- a/src/mongo/util/net/ssl_manager.cpp
+++ b/src/mongo/util/net/ssl_manager.cpp
@@ -402,15 +402,16 @@ SSLManagerCoordinator::SSLManagerCoordinator()
}
void ClusterMemberDNOverride::append(OperationContext* opCtx,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
auto value = clusterMemberOverride.get();
if (value) {
- b.append(name, value->fullDN.toString());
+ b->append(name, value->fullDN.toString());
}
}
-Status ClusterMemberDNOverride::setFromString(const std::string& str) {
+Status ClusterMemberDNOverride::setFromString(StringData str, const boost::optional<TenantId>&) {
if (str.empty()) {
*clusterMemberOverride = boost::none;
return Status::OK();
diff --git a/src/mongo/util/net/ssl_manager.h b/src/mongo/util/net/ssl_manager.h
index a20ca9946f6..ae2682ba8a8 100644
--- a/src/mongo/util/net/ssl_manager.h
+++ b/src/mongo/util/net/ssl_manager.h
@@ -34,6 +34,7 @@
#include <string>
#include "mongo/config.h"
+#include "mongo/db/tenant_id.h"
#ifdef MONGO_CONFIG_SSL
@@ -67,12 +68,12 @@ const std::string getSSLVersion(const std::string& prefix, const std::string& su
/**
* Validation callback for setParameter 'opensslCipherConfig'.
*/
-Status validateOpensslCipherConfig(const std::string&);
+Status validateOpensslCipherConfig(const std::string&, const boost::optional<TenantId>&);
/**
* Validation callback for setParameter 'disableNonTLSConnectionLogging'.
*/
-Status validateDisableNonTLSConnectionLogging(const bool&);
+Status validateDisableNonTLSConnectionLogging(const bool&, const boost::optional<TenantId>&);
} // namespace mongo
#ifdef MONGO_CONFIG_SSL
diff --git a/src/mongo/util/net/ssl_parameters.cpp b/src/mongo/util/net/ssl_parameters.cpp
index 60ed9f0921e..25667a4cb25 100644
--- a/src/mongo/util/net/ssl_parameters.cpp
+++ b/src/mongo/util/net/ssl_parameters.cpp
@@ -75,25 +75,27 @@ std::once_flag warnForSSLMode;
} // namespace
void SSLModeServerParameter::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& fieldName) {
+ BSONObjBuilder* builder,
+ StringData fieldName,
+ const boost::optional<TenantId>&) {
std::call_once(warnForSSLMode, [] {
LOGV2_WARNING(
23803, "Use of deprecated server parameter 'sslMode', please use 'tlsMode' instead.");
});
- builder.append(fieldName, SSLParams::sslModeFormat(sslGlobalParams.sslMode.load()));
+ builder->append(fieldName, SSLParams::sslModeFormat(sslGlobalParams.sslMode.load()));
}
void TLSModeServerParameter::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& fieldName) {
- builder.append(
+ BSONObjBuilder* builder,
+ StringData fieldName,
+ const boost::optional<TenantId>&) {
+ builder->append(
fieldName,
SSLParams::tlsModeFormat(static_cast<SSLParams::SSLModes>(sslGlobalParams.sslMode.load())));
}
-Status SSLModeServerParameter::setFromString(const std::string& strMode) {
+Status SSLModeServerParameter::setFromString(StringData strMode, const boost::optional<TenantId>&) {
std::call_once(warnForSSLMode, [] {
LOGV2_WARNING(
23804, "Use of deprecated server parameter 'sslMode', please use 'tlsMode' instead.");
@@ -108,7 +110,7 @@ Status SSLModeServerParameter::setFromString(const std::string& strMode) {
return Status::OK();
}
-Status TLSModeServerParameter::setFromString(const std::string& strMode) {
+Status TLSModeServerParameter::setFromString(StringData strMode, const boost::optional<TenantId>&) {
auto swNewMode = checkTLSModeTransition(
SSLParams::tlsModeFormat, SSLParams::tlsModeParse, "tlsMode", strMode);
if (!swNewMode.isOK()) {
@@ -119,10 +121,11 @@ Status TLSModeServerParameter::setFromString(const std::string& strMode) {
}
void TLSCATrustsSetParameter::append(OperationContext*,
- BSONObjBuilder& b,
- const std::string& name) {
+ BSONObjBuilder* b,
+ StringData name,
+ const boost::optional<TenantId>&) {
if (!sslGlobalParams.tlsCATrusts) {
- b.appendNull(name);
+ b->appendNull(name);
return;
}
@@ -145,7 +148,7 @@ void TLSCATrustsSetParameter::append(OperationContext*,
trusts.append(ca.obj());
}
- b.append(name, trusts.arr());
+ b->append(name, trusts.arr());
}
/**
@@ -174,7 +177,8 @@ void TLSCATrustsSetParameter::append(OperationContext*,
* { role: "read", db: "" } // May grant 'read' role on any DB.
* { role: "", db: "" } // May grant any role on any DB.
*/
-Status TLSCATrustsSetParameter::set(const BSONElement& element) try {
+Status TLSCATrustsSetParameter::set(const BSONElement& element,
+ const boost::optional<TenantId>&) try {
if ((element.type() != Object) || !element.Obj().couldBeArray()) {
return {ErrorCodes::BadValue, "Value must be an array"};
}
@@ -203,15 +207,17 @@ Status TLSCATrustsSetParameter::set(const BSONElement& element) try {
return exceptionToStatus();
}
-Status TLSCATrustsSetParameter::setFromString(const std::string& json) try {
- return set(BSON("" << fromjson(json)).firstElement());
+Status TLSCATrustsSetParameter::setFromString(StringData json,
+ const boost::optional<TenantId>&) try {
+ return set(BSON("" << fromjson(json)).firstElement(), boost::none);
} catch (...) {
return exceptionToStatus();
}
} // namespace mongo
-mongo::Status mongo::validateOpensslCipherConfig(const std::string&) {
+mongo::Status mongo::validateOpensslCipherConfig(const std::string&,
+ const boost::optional<TenantId>&) {
if (sslGlobalParams.sslCipherConfig != kSSLCipherConfigDefault) {
return {ErrorCodes::BadValue,
"opensslCipherConfig setParameter is incompatible with net.tls.tlsCipherConfig"};
@@ -226,7 +232,8 @@ mongo::Status mongo::validateOpensslCipherConfig(const std::string&) {
return Status::OK();
}
-mongo::Status mongo::validateDisableNonTLSConnectionLogging(const bool&) {
+mongo::Status mongo::validateDisableNonTLSConnectionLogging(const bool&,
+ const boost::optional<TenantId>&) {
if (sslGlobalParams.disableNonSSLConnectionLoggingSet) {
return {ErrorCodes::BadValue,
"Error parsing command line: Multiple occurrences of option "
diff --git a/src/mongo/util/net/ssl_parameters.h b/src/mongo/util/net/ssl_parameters.h
index c0089be45c5..4c9acefc690 100644
--- a/src/mongo/util/net/ssl_parameters.h
+++ b/src/mongo/util/net/ssl_parameters.h
@@ -29,21 +29,23 @@
#pragma once
+#include <boost/optional.hpp>
#include <string>
#include "mongo/base/status.h"
+#include "mongo/db/tenant_id.h"
namespace mongo {
/**
* Validation callback for setParameter 'opensslCipherConfig'.
*/
-Status validateOpensslCipherConfig(const std::string&);
+Status validateOpensslCipherConfig(const std::string&, const boost::optional<TenantId>&);
/**
* Validation callback for setParameter 'disableNonTLSConnectionLogging'.
*/
-Status validateDisableNonTLSConnectionLogging(const bool&);
+Status validateDisableNonTLSConnectionLogging(const bool&, const boost::optional<TenantId>&);
/**
* Records that disableNonTLSConnectionLogging has been set.
diff --git a/src/mongo/util/net/ssl_parameters_auth.cpp b/src/mongo/util/net/ssl_parameters_auth.cpp
index f88e2bd3302..389992cdd40 100644
--- a/src/mongo/util/net/ssl_parameters_auth.cpp
+++ b/src/mongo/util/net/ssl_parameters_auth.cpp
@@ -40,13 +40,15 @@
namespace mongo {
void ClusterAuthModeServerParameter::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& fieldName) {
+ BSONObjBuilder* builder,
+ StringData fieldName,
+ const boost::optional<TenantId>&) {
const auto clusterAuthMode = ClusterAuthMode::get(getGlobalServiceContext());
- builder.append(fieldName, clusterAuthMode.toString());
+ builder->append(fieldName, clusterAuthMode.toString());
}
-Status ClusterAuthModeServerParameter::setFromString(const std::string& strMode) try {
+Status ClusterAuthModeServerParameter::setFromString(StringData strMode,
+ const boost::optional<TenantId>&) try {
auto mode = uassertStatusOK(ClusterAuthMode::parse(strMode));
auto sslMode = sslGlobalParams.sslMode.load();
diff --git a/src/mongo/util/tcmalloc_server_status_section.cpp b/src/mongo/util/tcmalloc_server_status_section.cpp
index b8627507d87..2df8d9022d6 100644
--- a/src/mongo/util/tcmalloc_server_status_section.cpp
+++ b/src/mongo/util/tcmalloc_server_status_section.cpp
@@ -50,10 +50,12 @@ namespace mongo {
// TODO: Remove these implementations and the associated IDL definition in 4.3.
void TCMallocEnableMarkThreadTemporarilyIdle::append(OperationContext*,
- BSONObjBuilder&,
- const std::string&) {}
+ BSONObjBuilder*,
+ StringData,
+ const boost::optional<TenantId>&) {}
-Status TCMallocEnableMarkThreadTemporarilyIdle::setFromString(const std::string&) {
+Status TCMallocEnableMarkThreadTemporarilyIdle::setFromString(StringData,
+ const boost::optional<TenantId>&) {
return Status(ErrorCodes::BadValue,
"tcmallocEnableMarkThreadTemporarilyIdle has been removed. Setting this "
"parameter has no effect and it will be removed in a future version of "
diff --git a/src/mongo/util/tcmalloc_set_parameter.cpp b/src/mongo/util/tcmalloc_set_parameter.cpp
index 3bf03f9e19f..de3af048939 100644
--- a/src/mongo/util/tcmalloc_set_parameter.cpp
+++ b/src/mongo/util/tcmalloc_set_parameter.cpp
@@ -93,28 +93,30 @@ StatusWith<size_t> validateTCMallocValue(StringData name, const BSONElement& new
} // namespace
-#define TCMALLOC_SP_METHODS(cls) \
- void TCMalloc##cls##ServerParameter::append( \
- OperationContext*, BSONObjBuilder& b, const std::string& name) { \
- auto swValue = getProperty(k##cls##PropertyName); \
- if (swValue.isOK()) { \
- b.appendNumber(name, static_cast<long long>(swValue.getValue())); \
- } \
- } \
- Status TCMalloc##cls##ServerParameter::set(const BSONElement& newValueElement) { \
- auto swValue = validateTCMallocValue(name(), newValueElement); \
- if (!swValue.isOK()) { \
- return swValue.getStatus(); \
- } \
- return setProperty(k##cls##PropertyName, swValue.getValue()); \
- } \
- Status TCMalloc##cls##ServerParameter::setFromString(const std::string& str) { \
- size_t value; \
- Status status = NumberParser{}(str, &value); \
- if (!status.isOK()) { \
- return status; \
- } \
- return setProperty(k##cls##PropertyName, value); \
+#define TCMALLOC_SP_METHODS(cls) \
+ void TCMalloc##cls##ServerParameter::append( \
+ OperationContext*, BSONObjBuilder* b, StringData name, const boost::optional<TenantId>&) { \
+ auto swValue = getProperty(k##cls##PropertyName); \
+ if (swValue.isOK()) { \
+ b->appendNumber(name, static_cast<long long>(swValue.getValue())); \
+ } \
+ } \
+ Status TCMalloc##cls##ServerParameter::set(const BSONElement& newValueElement, \
+ const boost::optional<TenantId>&) { \
+ auto swValue = validateTCMallocValue(name(), newValueElement); \
+ if (!swValue.isOK()) { \
+ return swValue.getStatus(); \
+ } \
+ return setProperty(k##cls##PropertyName, swValue.getValue()); \
+ } \
+ Status TCMalloc##cls##ServerParameter::setFromString(StringData str, \
+ const boost::optional<TenantId>&) { \
+ size_t value; \
+ Status status = NumberParser{}(str, &value); \
+ if (!status.isOK()) { \
+ return status; \
+ } \
+ return setProperty(k##cls##PropertyName, value); \
}
TCMALLOC_SP_METHODS(MaxTotalThreadCacheBytes)
@@ -145,13 +147,15 @@ MONGO_INITIALIZER_GENERAL(TcmallocConfigurationDefaults, (), ("BeginStartupOptio
// setParameter for tcmalloc_release_rate
void TCMallocReleaseRateServerParameter::append(OperationContext*,
- BSONObjBuilder& builder,
- const std::string& fieldName) {
+ BSONObjBuilder* builder,
+ StringData fieldName,
+ const boost::optional<TenantId>&) {
auto value = MallocExtension::instance()->GetMemoryReleaseRate();
- builder.append(fieldName, value);
+ builder->append(fieldName, value);
}
-Status TCMallocReleaseRateServerParameter::setFromString(const std::string& tcmalloc_release_rate) {
+Status TCMallocReleaseRateServerParameter::setFromString(StringData tcmalloc_release_rate,
+ const boost::optional<TenantId>&) {
double value;
Status status = NumberParser{}(tcmalloc_release_rate, &value);
if (!status.isOK()) {
diff --git a/src/mongo/watchdog/watchdog_mongod.cpp b/src/mongo/watchdog/watchdog_mongod.cpp
index 9b423069b87..33f0f223ec8 100644
--- a/src/mongo/watchdog/watchdog_mongod.cpp
+++ b/src/mongo/watchdog/watchdog_mongod.cpp
@@ -76,7 +76,7 @@ WatchdogMonitor* getGlobalWatchdogMonitor() {
} // namespace
-Status validateWatchdogPeriodSeconds(const int& value) {
+Status validateWatchdogPeriodSeconds(const int& value, const boost::optional<TenantId>&) {
if (value < 60 && value != -1) {
return {ErrorCodes::BadValue, "watchdogPeriodSeconds must be greater than or equal to 60s"};
diff --git a/src/mongo/watchdog/watchdog_mongod.h b/src/mongo/watchdog/watchdog_mongod.h
index bfa7f4b711d..ace19d9695a 100644
--- a/src/mongo/watchdog/watchdog_mongod.h
+++ b/src/mongo/watchdog/watchdog_mongod.h
@@ -29,7 +29,10 @@
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/base/status.h"
+#include "mongo/db/tenant_id.h"
namespace mongo {
@@ -43,7 +46,7 @@ void startWatchdog(ServiceContext* service);
/**
* Callbacks used by the 'watchdogPeriodSeconds' set parameter.
*/
-Status validateWatchdogPeriodSeconds(const int& value);
+Status validateWatchdogPeriodSeconds(const int& value, const boost::optional<TenantId>&);
Status onUpdateWatchdogPeriodSeconds(const int& value);
} // namespace mongo