summaryrefslogtreecommitdiff
path: root/src/mongo/db/auth
diff options
context:
space:
mode:
authorGabriel Russell <gabriel.russell@mongodb.com>2020-02-13 11:49:46 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-13 18:16:35 +0000
commita84c09a19720b73cedb2e8ef7c5cfeedfa1c9761 (patch)
tree85ac46cd5f4ea6d5134560bf764fb9e6cf11fe4e /src/mongo/db/auth
parent6df40e01f7b6899affc4536e7e73a35802cabf98 (diff)
downloadmongo-a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761.tar.gz
SERVER-45869 automatically converted structured logging
Diffstat (limited to 'src/mongo/db/auth')
-rw-r--r--src/mongo/db/auth/authorization_manager_impl.cpp43
-rw-r--r--src/mongo/db/auth/authorization_session_impl.cpp59
-rw-r--r--src/mongo/db/auth/authz_session_external_state_server_common.cpp7
-rw-r--r--src/mongo/db/auth/sasl_commands.cpp25
-rw-r--r--src/mongo/db/auth/sasl_mechanism_registry.cpp6
-rw-r--r--src/mongo/db/auth/sasl_scram_test.cpp5
-rw-r--r--src/mongo/db/auth/security_key.cpp29
-rw-r--r--src/mongo/db/auth/user_cache_invalidator_job.cpp54
8 files changed, 153 insertions, 75 deletions
diff --git a/src/mongo/db/auth/authorization_manager_impl.cpp b/src/mongo/db/auth/authorization_manager_impl.cpp
index f996254981d..603cf4c924c 100644
--- a/src/mongo/db/auth/authorization_manager_impl.cpp
+++ b/src/mongo/db/auth/authorization_manager_impl.cpp
@@ -51,6 +51,7 @@
#include "mongo/db/auth/user_management_commands_parser.h"
#include "mongo/db/global_settings.h"
#include "mongo/db/mongod_options.h"
+#include "mongo/logv2/log.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
#include "mongo/util/str.h"
@@ -413,7 +414,7 @@ StatusWith<UserHandle> AuthorizationManagerImpl::acquireUser(OperationContext* o
auto cachedUser = _userCache.acquire(opCtx, userName);
invariant(cachedUser);
- LOG(1) << "Returning user " << userName << " from cache";
+ LOGV2_DEBUG(20226, 1, "Returning user {userName} from cache", "userName"_attr = userName);
return cachedUser;
} catch (const DBException& ex) {
return ex.toStatus();
@@ -442,7 +443,7 @@ void AuthorizationManagerImpl::updatePinnedUsersList(std::vector<UserName> names
bool noUsersToPin = _usersToPin->empty();
_pinnedUsersCond.notify_one();
if (noUsersToPin) {
- LOG(1) << "There were no users to pin, not starting tracker thread";
+ LOGV2_DEBUG(20227, 1, "There were no users to pin, not starting tracker thread");
return;
}
@@ -456,7 +457,7 @@ void AuthorizationManagerImpl::_pinnedUsersThreadRoutine() noexcept try {
Client::initThread("PinnedUsersTracker");
std::list<UserHandle> pinnedUsers;
std::vector<UserName> usersToPin;
- LOG(1) << "Starting pinned users tracking thread";
+ LOGV2_DEBUG(20228, 1, "Starting pinned users tracking thread");
while (true) {
auto opCtx = cc().makeOperationContext();
@@ -485,13 +486,22 @@ void AuthorizationManagerImpl::_pinnedUsersThreadRoutine() noexcept try {
if (!user.isValid() || !shouldPin) {
if (!shouldPin) {
- LOG(2) << "Unpinning user " << user->getName();
+ LOGV2_DEBUG(20229,
+ 2,
+ "Unpinning user {user_getName}",
+ "user_getName"_attr = user->getName());
} else {
- LOG(2) << "Pinned user no longer valid, will re-pin " << user->getName();
+ LOGV2_DEBUG(20230,
+ 2,
+ "Pinned user no longer valid, will re-pin {user_getName}",
+ "user_getName"_attr = user->getName());
}
it = pinnedUsers.erase(it);
} else {
- LOG(3) << "Pinned user is still valid and pinned " << user->getName();
+ LOGV2_DEBUG(20231,
+ 3,
+ "Pinned user is still valid and pinned {user_getName}",
+ "user_getName"_attr = user->getName());
++it;
}
}
@@ -506,42 +516,45 @@ void AuthorizationManagerImpl::_pinnedUsersThreadRoutine() noexcept try {
auto swUser = acquireUser(opCtx.get(), userName);
if (swUser.isOK()) {
- LOG(2) << "Pinned user " << userName;
+ LOGV2_DEBUG(20232, 2, "Pinned user {userName}", "userName"_attr = userName);
pinnedUsers.emplace_back(std::move(swUser.getValue()));
} else {
const auto& status = swUser.getStatus();
// If the user is not found, then it might just not exist yet. Skip this user for
// now.
if (status != ErrorCodes::UserNotFound) {
- warning() << "Unable to fetch pinned user " << userName.toString() << ": "
- << status;
+ LOGV2_WARNING(20239,
+ "Unable to fetch pinned user {userName}: {status}",
+ "userName"_attr = userName.toString(),
+ "status"_attr = status);
} else {
- LOG(2) << "Pinned user not found: " << userName;
+ LOGV2_DEBUG(
+ 20233, 2, "Pinned user not found: {userName}", "userName"_attr = userName);
}
}
}
}
} catch (const ExceptionFor<ErrorCodes::InterruptedAtShutdown>&) {
- LOG(1) << "Ending pinned users tracking thread";
+ LOGV2_DEBUG(20234, 1, "Ending pinned users tracking thread");
return;
}
void AuthorizationManagerImpl::invalidateUserByName(OperationContext* opCtx,
const UserName& userName) {
- LOG(2) << "Invalidating user " << userName;
+ LOGV2_DEBUG(20235, 2, "Invalidating user {userName}", "userName"_attr = userName);
_authSchemaVersionCache.invalidateAll();
_userCache.invalidate(userName);
}
void AuthorizationManagerImpl::invalidateUsersFromDB(OperationContext* opCtx, StringData dbname) {
- LOG(2) << "Invalidating all users from database " << dbname;
+ LOGV2_DEBUG(20236, 2, "Invalidating all users from database {dbname}", "dbname"_attr = dbname);
_authSchemaVersionCache.invalidateAll();
_userCache.invalidateIf(
[&](const UserName& user, const User*) { return user.getDB() == dbname; });
}
void AuthorizationManagerImpl::invalidateUserCache(OperationContext* opCtx) {
- LOG(2) << "Invalidating user cache";
+ LOGV2_DEBUG(20237, 2, "Invalidating user cache");
_authSchemaVersionCache.invalidateAll();
_userCache.invalidateAll();
}
@@ -603,7 +616,7 @@ AuthorizationManagerImpl::UserCacheImpl::UserCacheImpl(
boost::optional<User> AuthorizationManagerImpl::UserCacheImpl::lookup(OperationContext* opCtx,
const UserName& userName) {
- LOG(1) << "Getting user " << userName << " from disk";
+ LOGV2_DEBUG(20238, 1, "Getting user {userName} from disk", "userName"_attr = userName);
// Number of times to retry a user document that fetches due to transient AuthSchemaIncompatible
// errors. These errors should only ever occur during and shortly after schema upgrades.
diff --git a/src/mongo/db/auth/authorization_session_impl.cpp b/src/mongo/db/auth/authorization_session_impl.cpp
index 941f3b84cf8..c0beeb758aa 100644
--- a/src/mongo/db/auth/authorization_session_impl.cpp
+++ b/src/mongo/db/auth/authorization_session_impl.cpp
@@ -53,6 +53,7 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/pipeline/aggregation_request.h"
#include "mongo/db/pipeline/lite_parsed_pipeline.h"
+#include "mongo/logv2/log.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
#include "mongo/util/str.h"
@@ -139,8 +140,11 @@ Status AuthorizationSessionImpl::addAndAuthorizeUser(OperationContext* opCtx,
Status restrictionStatus =
restrictionSet.validate(RestrictionEnvironment::get(*opCtx->getClient()));
if (!restrictionStatus.isOK()) {
- log() << "Failed to acquire user '" << userName
- << "' because of unmet authentication restrictions: " << restrictionStatus.reason();
+ LOGV2(20240,
+ "Failed to acquire user '{userName}' because of unmet authentication restrictions: "
+ "{restrictionStatus_reason}",
+ "userName"_attr = userName,
+ "restrictionStatus_reason"_attr = restrictionStatus.reason());
return AuthorizationManager::authenticationFailedStatus;
}
@@ -553,9 +557,11 @@ bool AuthorizationSessionImpl::isAuthorizedToCreateRole(
return true;
}
}
- log() << "Not authorized to create the first role in the system '" << args.roleName
- << "' using the localhost exception. The user needs to acquire the role through "
- "external authentication first.";
+ LOGV2(20241,
+ "Not authorized to create the first role in the system '{args_roleName}' using the "
+ "localhost exception. The user needs to acquire the role through "
+ "external authentication first.",
+ "args_roleName"_attr = args.roleName);
}
return false;
@@ -765,45 +771,56 @@ void AuthorizationSessionImpl::_refreshUserInfoAsNeeded(OperationContext* opCtx)
Status restrictionStatus = restrictionSet.validate(
RestrictionEnvironment::get(*opCtx->getClient()));
if (!restrictionStatus.isOK()) {
- log() << "Removed user " << name
- << " with unmet authentication restrictions from session cache of"
- << " user information. Restriction failed because: "
- << restrictionStatus.reason();
+ LOGV2(20242,
+ "Removed user {name} with unmet authentication restrictions from "
+ "session cache of user information. Restriction failed because: "
+ "{restrictionStatus_reason}",
+ "name"_attr = name,
+ "restrictionStatus_reason"_attr = restrictionStatus.reason());
// If we remove from the UserSet, we cannot increment the iterator.
continue;
}
} catch (...) {
- log() << "Evaluating authentication restrictions for " << name
- << " resulted in an unknown exception. Removing user from the"
- << " session cache.";
+ LOGV2(20243,
+ "Evaluating authentication restrictions for {name} resulted in an "
+ "unknown exception. Removing user from the session cache.",
+ "name"_attr = name);
continue;
}
// Success! Replace the old User object with the updated one.
removeGuard.dismiss();
_authenticatedUsers.replaceAt(it, std::move(updatedUser));
- LOG(1) << "Updated session cache of user information for " << name;
+ LOGV2_DEBUG(20244,
+ 1,
+ "Updated session cache of user information for {name}",
+ "name"_attr = name);
break;
}
case ErrorCodes::UserNotFound: {
// User does not exist anymore; remove it from _authenticatedUsers.
- log() << "Removed deleted user " << name
- << " from session cache of user information.";
+ LOGV2(20245,
+ "Removed deleted user {name} from session cache of user information.",
+ "name"_attr = name);
continue; // No need to advance "it" in this case.
}
case ErrorCodes::UnsupportedFormat: {
// An auth subsystem has explicitly indicated a failure.
- log() << "Removed user " << name
- << " from session cache of user information because of refresh failure:"
- << " '" << status << "'.";
+ LOGV2(20246,
+ "Removed user {name} from session cache of user information because of "
+ "refresh failure: '{status}'.",
+ "name"_attr = name,
+ "status"_attr = status);
continue; // No need to advance "it" in this case.
}
default:
// Unrecognized error; assume that it's transient, and continue working with the
// out-of-date privilege data.
- warning() << "Could not fetch updated user privilege information for " << name
- << "; continuing to use old information. Reason is "
- << redact(status);
+ LOGV2_WARNING(20247,
+ "Could not fetch updated user privilege information for {name}; "
+ "continuing to use old information. Reason is {status}",
+ "name"_attr = name,
+ "status"_attr = redact(status));
removeGuard.dismiss();
break;
}
diff --git a/src/mongo/db/auth/authz_session_external_state_server_common.cpp b/src/mongo/db/auth/authz_session_external_state_server_common.cpp
index b9829fde37e..9b29806013b 100644
--- a/src/mongo/db/auth/authz_session_external_state_server_common.cpp
+++ b/src/mongo/db/auth/authz_session_external_state_server_common.cpp
@@ -38,6 +38,7 @@
#include "mongo/base/status.h"
#include "mongo/db/auth/enable_localhost_auth_bypass_parameter_gen.h"
#include "mongo/db/client.h"
+#include "mongo/logv2/log.h"
#include "mongo/util/debug_util.h"
#include "mongo/util/log.h"
@@ -70,9 +71,9 @@ void AuthzSessionExternalStateServerCommon::_checkShouldAllowLocalhost(Operation
_allowLocalhost = !_authzManager->hasAnyPrivilegeDocuments(opCtx);
if (_allowLocalhost) {
std::call_once(checkShouldAllowLocalhostOnceFlag, []() {
- log() << "note: no users configured in admin.system.users, allowing localhost "
- "access"
- << std::endl;
+ LOGV2(20248,
+ "note: no users configured in admin.system.users, allowing localhost "
+ "access");
});
}
}
diff --git a/src/mongo/db/auth/sasl_commands.cpp b/src/mongo/db/auth/sasl_commands.cpp
index a6276d3fec9..22403e23303 100644
--- a/src/mongo/db/auth/sasl_commands.cpp
+++ b/src/mongo/db/auth/sasl_commands.cpp
@@ -53,6 +53,7 @@
#include "mongo/db/commands/authentication_commands.h"
#include "mongo/db/server_options.h"
#include "mongo/db/stats/counters.h"
+#include "mongo/logv2/log.h"
#include "mongo/util/base64.h"
#include "mongo/util/log.h"
#include "mongo/util/sequence_util.h"
@@ -187,10 +188,15 @@ Status doSaslStep(OperationContext* opCtx,
StatusWith<std::string> swResponse = mechanism.step(opCtx, payload);
if (!swResponse.isOK()) {
- log() << "SASL " << mechanism.mechanismName() << " authentication failed for "
- << mechanism.getPrincipalName() << " on " << mechanism.getAuthenticationDatabase()
- << " from client " << opCtx->getClient()->getRemote().toString() << " ; "
- << redact(swResponse.getStatus());
+ LOGV2(20249,
+ "SASL {mechanism_mechanismName} authentication failed for "
+ "{mechanism_getPrincipalName} on {mechanism_getAuthenticationDatabase} from client "
+ "{opCtx_getClient_getRemote} ; {swResponse_getStatus}",
+ "mechanism_mechanismName"_attr = mechanism.mechanismName(),
+ "mechanism_getPrincipalName"_attr = mechanism.getPrincipalName(),
+ "mechanism_getAuthenticationDatabase"_attr = mechanism.getAuthenticationDatabase(),
+ "opCtx_getClient_getRemote"_attr = opCtx->getClient()->getRemote().toString(),
+ "swResponse_getStatus"_attr = redact(swResponse.getStatus()));
sleepmillis(saslGlobalParams.authFailedDelay.load());
// All the client needs to know is that authentication has failed.
@@ -211,9 +217,14 @@ Status doSaslStep(OperationContext* opCtx,
}
if (!serverGlobalParams.quiet.load()) {
- log() << "Successfully authenticated as principal " << mechanism.getPrincipalName()
- << " on " << mechanism.getAuthenticationDatabase() << " from client "
- << opCtx->getClient()->session()->remote();
+ LOGV2(20250,
+ "Successfully authenticated as principal {mechanism_getPrincipalName} on "
+ "{mechanism_getAuthenticationDatabase} from client "
+ "{opCtx_getClient_session_remote}",
+ "mechanism_getPrincipalName"_attr = mechanism.getPrincipalName(),
+ "mechanism_getAuthenticationDatabase"_attr =
+ mechanism.getAuthenticationDatabase(),
+ "opCtx_getClient_session_remote"_attr = opCtx->getClient()->session()->remote());
}
if (session->isSpeculative()) {
authCounter.incSpeculativeAuthenticateSuccessful(mechanism.mechanismName().toString());
diff --git a/src/mongo/db/auth/sasl_mechanism_registry.cpp b/src/mongo/db/auth/sasl_mechanism_registry.cpp
index 741dde39126..5c07d4e2eac 100644
--- a/src/mongo/db/auth/sasl_mechanism_registry.cpp
+++ b/src/mongo/db/auth/sasl_mechanism_registry.cpp
@@ -35,6 +35,7 @@
#include "mongo/base/init.h"
#include "mongo/db/auth/sasl_options.h"
#include "mongo/db/auth/user.h"
+#include "mongo/logv2/log.h"
#include "mongo/util/icu.h"
#include "mongo/util/log.h"
#include "mongo/util/net/socket_utils.h"
@@ -108,8 +109,9 @@ void SASLServerMechanismRegistry::advertiseMechanismNamesForUser(OperationContex
if (!swUser.isOK()) {
auto& status = swUser.getStatus();
if (status.code() == ErrorCodes::UserNotFound) {
- log() << "Supported SASL mechanisms requested for unknown user '" << userName
- << "'";
+ LOGV2(20251,
+ "Supported SASL mechanisms requested for unknown user '{userName}'",
+ "userName"_attr = userName);
return;
}
uassertStatusOK(status);
diff --git a/src/mongo/db/auth/sasl_scram_test.cpp b/src/mongo/db/auth/sasl_scram_test.cpp
index 23c6c548f3c..4b2ec0b84d5 100644
--- a/src/mongo/db/auth/sasl_scram_test.cpp
+++ b/src/mongo/db/auth/sasl_scram_test.cpp
@@ -47,6 +47,7 @@
#include "mongo/db/auth/sasl_mechanism_registry.h"
#include "mongo/db/auth/sasl_scram_server_conversation.h"
#include "mongo/db/service_context.h"
+#include "mongo/logv2/log.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/base64.h"
#include "mongo/util/log.h"
@@ -270,12 +271,12 @@ protected:
public:
void run() {
- log() << "SCRAM-SHA-1 variant";
+ LOGV2(20252, "SCRAM-SHA-1 variant");
saslServerSession = std::make_unique<SaslSCRAMSHA1ServerMechanism>("test");
_digestPassword = true;
Test::run();
- log() << "SCRAM-SHA-256 variant";
+ LOGV2(20253, "SCRAM-SHA-256 variant");
saslServerSession = std::make_unique<SaslSCRAMSHA256ServerMechanism>("test");
_digestPassword = false;
Test::run();
diff --git a/src/mongo/db/auth/security_key.cpp b/src/mongo/db/auth/security_key.cpp
index fe310befdf2..5fb3d1badd4 100644
--- a/src/mongo/db/auth/security_key.cpp
+++ b/src/mongo/db/auth/security_key.cpp
@@ -52,6 +52,7 @@
#include "mongo/db/auth/security_file.h"
#include "mongo/db/auth/user.h"
#include "mongo/db/server_options.h"
+#include "mongo/logv2/log.h"
#include "mongo/util/icu.h"
#include "mongo/util/log.h"
#include "mongo/util/password_digest.h"
@@ -70,15 +71,20 @@ public:
boost::optional<User::CredentialData> generate(const std::string& password) {
if (password.size() < kMinKeyLength || password.size() > kMaxKeyLength) {
- error() << " security key in " << _filename << " has length " << password.size()
- << ", must be between 6 and 1024 chars";
+ LOGV2_ERROR(20255,
+ " security key in {filename} has length {password_size}, must be between 6 "
+ "and 1024 chars",
+ "filename"_attr = _filename,
+ "password_size"_attr = password.size());
return boost::none;
}
auto swSaslPassword = icuSaslPrep(password);
if (!swSaslPassword.isOK()) {
- error() << "Could not prep security key file for SCRAM-SHA-256: "
- << swSaslPassword.getStatus();
+ LOGV2_ERROR(
+ 20256,
+ "Could not prep security key file for SCRAM-SHA-256: {swSaslPassword_getStatus}",
+ "swSaslPassword_getStatus"_attr = swSaslPassword.getStatus());
return boost::none;
}
const auto passwordDigest = mongo::createPasswordDigest(
@@ -109,7 +115,9 @@ private:
target.storedKey = source[scram::kStoredKeyFieldName].String();
target.serverKey = source[scram::kServerKeyFieldName].String();
if (!target.isValid()) {
- error() << "Could not generate valid credentials from key in " << _filename;
+ LOGV2_ERROR(20257,
+ "Could not generate valid credentials from key in {filename}",
+ "filename"_attr = _filename);
return false;
}
@@ -128,15 +136,20 @@ using std::string;
bool setUpSecurityKey(const string& filename) {
auto swKeyStrings = mongo::readSecurityFile(filename);
if (!swKeyStrings.isOK()) {
- log() << swKeyStrings.getStatus().reason();
+ LOGV2(20254,
+ "{swKeyStrings_getStatus_reason}",
+ "swKeyStrings_getStatus_reason"_attr = swKeyStrings.getStatus().reason());
return false;
}
auto keyStrings = std::move(swKeyStrings.getValue());
if (keyStrings.size() > 2) {
- error() << "Only two keys are supported in the security key file, " << keyStrings.size()
- << " are specified in " << filename;
+ LOGV2_ERROR(20258,
+ "Only two keys are supported in the security key file, {keyStrings_size} are "
+ "specified in {filename}",
+ "keyStrings_size"_attr = keyStrings.size(),
+ "filename"_attr = filename);
return false;
}
diff --git a/src/mongo/db/auth/user_cache_invalidator_job.cpp b/src/mongo/db/auth/user_cache_invalidator_job.cpp
index 771194c14c6..d301173441e 100644
--- a/src/mongo/db/auth/user_cache_invalidator_job.cpp
+++ b/src/mongo/db/auth/user_cache_invalidator_job.cpp
@@ -42,6 +42,7 @@
#include "mongo/db/auth/user_cache_invalidator_job_parameters_gen.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
+#include "mongo/logv2/log.h"
#include "mongo/platform/compiler.h"
#include "mongo/platform/mutex.h"
#include "mongo/rpc/get_status_from_command_result.h"
@@ -63,7 +64,11 @@ public:
void setInterval(Seconds interval) {
{
stdx::lock_guard<Latch> twiddle(_mutex);
- LOG(5) << "setInterval: old=" << _interval << ", new=" << interval;
+ LOGV2_DEBUG(20259,
+ 5,
+ "setInterval: old={interval}, new={interval2}",
+ "interval"_attr = _interval,
+ "interval2"_attr = interval);
_interval = interval;
}
_condition.notify_all();
@@ -94,15 +99,19 @@ public:
Date_t now = Date_t::now();
Date_t expiry = _last + _interval;
- LOG(5) << "wait: now=" << now << ", expiry=" << expiry;
+ LOGV2_DEBUG(20260,
+ 5,
+ "wait: now={now}, expiry={expiry}",
+ "now"_attr = now,
+ "expiry"_attr = expiry);
if (now >= expiry) {
_last = now;
- LOG(5) << "wait: done";
+ LOGV2_DEBUG(20261, 5, "wait: done");
return true;
}
- LOG(5) << "wait: blocking";
+ LOGV2_DEBUG(20262, 5, "wait: blocking");
MONGO_IDLE_THREAD_BLOCK;
_condition.wait_until(lock, expiry.toSystemTimePoint());
}
@@ -165,13 +174,15 @@ void UserCacheInvalidator::initialize(OperationContext* opCtx) {
}
if (currentGeneration.getStatus().code() == ErrorCodes::CommandNotFound) {
- warning() << "_getUserCacheGeneration command not found while fetching initial user "
- "cache generation from the config server(s). This most likely means you are "
- "running an outdated version of mongod on the config servers";
+ LOGV2_WARNING(20264,
+ "_getUserCacheGeneration command not found while fetching initial user "
+ "cache generation from the config server(s). This most likely means you are "
+ "running an outdated version of mongod on the config servers");
} else {
- warning() << "An error occurred while fetching initial user cache generation from "
- "config servers: "
- << currentGeneration.getStatus();
+ LOGV2_WARNING(20265,
+ "An error occurred while fetching initial user cache generation from "
+ "config servers: {currentGeneration_getStatus}",
+ "currentGeneration_getStatus"_attr = currentGeneration.getStatus());
}
_previousCacheGeneration = OID();
}
@@ -184,26 +195,35 @@ void UserCacheInvalidator::run() {
auto opCtx = cc().makeOperationContext();
StatusWith<OID> currentGeneration = getCurrentCacheGeneration(opCtx.get());
if (!currentGeneration.isOK()) {
- warning() << "An error occurred while fetching current user cache generation "
- "to check if user cache needs invalidation: "
- << currentGeneration.getStatus();
+ LOGV2_WARNING(
+ 20266,
+ "An error occurred while fetching current user cache generation "
+ "to check if user cache needs invalidation: {currentGeneration_getStatus}",
+ "currentGeneration_getStatus"_attr = currentGeneration.getStatus());
// When in doubt, invalidate the cache
try {
_authzManager->invalidateUserCache(opCtx.get());
} catch (const DBException& e) {
- warning() << "Error invalidating user cache: " << e.toStatus();
+ LOGV2_WARNING(20267,
+ "Error invalidating user cache: {e_toStatus}",
+ "e_toStatus"_attr = e.toStatus());
}
continue;
}
if (currentGeneration.getValue() != _previousCacheGeneration) {
- log() << "User cache generation changed from " << _previousCacheGeneration << " to "
- << currentGeneration.getValue() << "; invalidating user cache";
+ LOGV2(20263,
+ "User cache generation changed from {previousCacheGeneration} to "
+ "{currentGeneration_getValue}; invalidating user cache",
+ "previousCacheGeneration"_attr = _previousCacheGeneration,
+ "currentGeneration_getValue"_attr = currentGeneration.getValue());
try {
_authzManager->invalidateUserCache(opCtx.get());
} catch (const DBException& e) {
- warning() << "Error invalidating user cache: " << e.toStatus();
+ LOGV2_WARNING(20268,
+ "Error invalidating user cache: {e_toStatus}",
+ "e_toStatus"_attr = e.toStatus());
}
_previousCacheGeneration = currentGeneration.getValue();