diff --git a/src/v/kafka/client/broker.cc b/src/v/kafka/client/broker.cc index 9f8542d0b25d..d896adfa195a 100644 --- a/src/v/kafka/client/broker.cc +++ b/src/v/kafka/client/broker.cc @@ -17,6 +17,27 @@ #include "rpc/rpc_utils.h" #include +#include + +#include + +namespace { +bool is_dns_failure_error(const std::system_error& e) { + if (e.code().category() == ss::net::dns::error_category()) { + switch (e.code().value()) { + case ARES_ENOTFOUND: + case ARES_ENODATA: + case ARES_ETIMEOUT: + case ARES_ECONNREFUSED: + return true; + default: + return false; + } + } + + return false; +} +} // namespace namespace kafka::client { @@ -50,7 +71,7 @@ ss::future make_broker( }); }) .handle_exception_type([node_id](const std::system_error& ex) { - if (net::is_reconnect_error(ex)) { + if (net::is_reconnect_error(ex) || is_dns_failure_error(ex)) { return ss::make_exception_future( broker_error(node_id, error_code::network_exception)); } diff --git a/src/v/net/connection.cc b/src/v/net/connection.cc index 8879be175994..92967f351baf 100644 --- a/src/v/net/connection.cc +++ b/src/v/net/connection.cc @@ -17,6 +17,8 @@ #include #include +#include + namespace net { /** @@ -40,7 +42,9 @@ bool is_reconnect_error(const std::system_error& e) { if (e.code().category() == ss::tls::error_category()) { return absl::c_any_of( ss_tls_reconnect_errors, [v](int ec) { return v == ec; }); - } else { + } else if ( + e.code().category() == std::system_category() + || e.code().category() == std::generic_category()) { switch (v) { case ECONNREFUSED: case ENETUNREACH: @@ -58,6 +62,9 @@ bool is_reconnect_error(const std::system_error& e) { default: return false; } + } else { + // We don't know what the error category is at this point + return false; } __builtin_unreachable(); }