Skip to content

Commit 733e432

Browse files
committed
MB-35589: Extend select bucket logging
Add log entries when select bucket fails due to EACCESS: INFO 61: select_bucket failed - Not authenticated. Followed by JSON with more information: { "cid": "127.0.0.1:39668/efbeadde", "connection": "[ 127.0.0.1:39668 - 127.0.0.1:37011 (not authenticated) ]", "bucket": "foo" } Change-Id: I904298e411dafa7dfb70e41f8b21dd40f3a34693 Reviewed-on: http://review.couchbase.org/113628 Reviewed-by: Matt Ingenthron <[email protected]> Reviewed-by: Dave Rigby <[email protected]> Tested-by: Trond Norbye <[email protected]>
1 parent 1974839 commit 733e432

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

daemon/protocol/mcbp/select_bucket_executor.cc

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,28 @@
2727
ENGINE_ERROR_CODE select_bucket(Cookie& cookie, const std::string& bucketname) {
2828
auto& connection = cookie.getConnection();
2929
if (!connection.isAuthenticated()) {
30+
cookie.setErrorContext("Not authenticated");
31+
LOG_INFO(
32+
"{}: select_bucket failed - Not authenticated. "
33+
R"({{"cid":"{}/{:x}","connection":"{}","bucket":"{}"}})",
34+
connection.getId(),
35+
connection.getConnectionId().data(),
36+
ntohl(cookie.getRequest().getOpaque()),
37+
connection.getDescription(),
38+
bucketname);
3039
return ENGINE_EACCESS;
3140
}
3241

3342
// We can't switch bucket if we've got multiple commands in flight
3443
if (connection.getNumberOfCookies() > 1) {
3544
LOG_INFO(
36-
"{}: {} select_bucket [{}] is not possible with multiple "
37-
"commands in flight",
45+
"{}: select_bucket failed - multiple commands in flight. "
46+
R"({{"cid":"{}/{:x}","connection":"{}","bucket":"{}"}})",
3847
connection.getId(),
39-
bucketname,
40-
connection.getDescription());
48+
connection.getConnectionId().data(),
49+
ntohl(cookie.getRequest().getOpaque()),
50+
connection.getDescription(),
51+
bucketname);
4152
return ENGINE_ENOTSUP;
4253
}
4354

@@ -72,6 +83,14 @@ ENGINE_ERROR_CODE select_bucket(Cookie& cookie, const std::string& bucketname) {
7283
return ENGINE_KEY_ENOENT;
7384
}
7485
} catch (const cb::rbac::Exception&) {
86+
LOG_INFO(
87+
"{}: select_bucket failed - No access. "
88+
R"({{"cid":"{}/{:x}","connection":"{}","bucket":"{}"}})",
89+
connection.getId(),
90+
connection.getConnectionId().data(),
91+
ntohl(cookie.getRequest().getOpaque()),
92+
connection.getDescription(),
93+
bucketname);
7594
return ENGINE_EACCESS;
7695
}
7796
}

0 commit comments

Comments
 (0)