-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
Server Serverless 2022-05-30, Server Serverless 2022-06-13, Server Serverless 2022-06-27, Server Serverless 2022-07-11, Server Serverless 2022-07-25
-
168
For any commands that use concatenate_with_db, we'll pass the tenantId, if it exists on the opMsgRequest, to the NamespaceString constructor. In order to do this, we'll need to pass tenantId to gen_namespace_check() (we'll need to pass it through _gen_command_deserializer())- it can default to None for both functions. In CommandWithNamespaceTypeInfo::gen_namespace_check(), pass this tenantId to IDLParserErrorContext::parseNSCollectionRequired. We'll have to add tenantId as an optional parameter to IDLParserErrorContext::parseNSCollectionRequired.
Once this is done, we should be able to successfully run some commands on a standalone mongod (or perhaps a single node RS) using either a securityToken or the $tenant field to pass the tenantId. Only commands which are IDL defined will work at this point, let's write a simple workload that runs create collection, some CRUD ops, and find commands using both the securityToken and $tenant.
Here are the example idl generated cpp code:
- for constructing the "to" field of "renameCollection"
if (MONGO_likely(ctxt.checkAndAssertType(commandElement, String))) {
_commandParameter = NamespaceString(request.getValidatedTenantId(), commandElement.valueStringData());
}
else {
ctxt.throwMissingField(kCommandParameterFieldName);
}
}
- for constructing the nss from command feild of "renameCollection" cmd. Its cmd namespace is "namespace: type".
{
if (MONGO_likely(ctxt.checkAndAssertType(commandElement, String))) {
_commandParameter = NamespaceString(request.getValidatedTenantId(), commandElement.valueStringData());
}
else {
ctxt.throwMissingField(kCommandParameterFieldName);
}
}
- for constructing the nss from db name and command field of "insert" cmd. Its cmd namespace is "namespace: concatenate_with_db".
invariant(_nss.isEmpty());
DatabaseName dbName(request.getValidatedTenantId(), _dbName);
_nss = ctxt.parseNSCollectionRequired(dbName, commandElement, false);
- depends on
-
SERVER-64608 Add tenantID to NamespaceString
- Closed
-
SERVER-65458 Parse and validate tenantId at the start of command processing
- Closed