Skip to content

Commit

Permalink
net: log auth errors at WARN level
Browse files Browse the repository at this point in the history
& with a message that distinguishes auth failures
from general errors.

This improves log hygiene on internet-facing clusters that
will typically receive malformed probing connections from
time to time.
  • Loading branch information
jcsp committed Jan 6, 2023
1 parent edc2baa commit 55344b5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/v/net/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ std::optional<ss::sstring> is_disconnect_exception(std::exception_ptr e) {
return std::nullopt;
}

bool is_auth_error(std::exception_ptr e) {
try {
rethrow_exception(e);
} catch (const authentication_exception& e) {
return true;
} catch (...) {
return false;
}

__builtin_unreachable();
}

connection::connection(
boost::intrusive::list<connection>& hook,
ss::sstring name,
Expand Down
2 changes: 2 additions & 0 deletions src/v/net/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace net {
bool is_reconnect_error(const std::system_error& e);
std::optional<ss::sstring> is_disconnect_exception(std::exception_ptr);

bool is_auth_error(std::exception_ptr);

class connection : public boost::intrusive::list_base_hook<> {
public:
connection(
Expand Down
15 changes: 14 additions & 1 deletion src/v/net/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,20 @@ static inline void print_exceptional_future(
auto disconnected = is_disconnect_exception(ex);

if (!disconnected) {
vlog(log.error, "Error[{}] remote address: {} - {}", ctx, address, ex);
if (is_auth_error(ex)) {
vlog(
log.warn,
"Authentication Failure[{}] remote address: {} - {}",
ctx,
address,
ex);
} else {
// Authentication exceptions are logged at WARN, not ERROR, because
// they generally point to a misbehaving client rather than a fault
// in the server.
vlog(
log.error, "Error[{}] remote address: {} - {}", ctx, address, ex);
}
} else {
vlog(
log.info,
Expand Down

0 comments on commit 55344b5

Please sign in to comment.