diff --git a/include/mgmt/rpc/server/CommBase.h b/include/mgmt/rpc/server/CommBase.h index 76e90f9776d..7dd0f896700 100644 --- a/include/mgmt/rpc/server/CommBase.h +++ b/include/mgmt/rpc/server/CommBase.h @@ -36,7 +36,7 @@ struct BaseCommInterface { virtual std::string const &name() const = 0; }; -enum class InternalError { MAX_TRANSIENT_ERRORS_HANDLED = 1, POLLIN_ERROR, PARTIAL_READ, FULL_BUFFER }; +enum class InternalError { MAX_TRANSIENT_ERRORS_HANDLED = 1, POLLIN_ERROR, PARTIAL_READ, FULL_BUFFER, INVALID_SOCKET_PATH }; std::error_code make_error_code(rpc::comm::InternalError e); } // namespace rpc::comm diff --git a/src/mgmt/rpc/server/CommBase.cc b/src/mgmt/rpc/server/CommBase.cc index 1bf7059264b..41ecb1cecd0 100644 --- a/src/mgmt/rpc/server/CommBase.cc +++ b/src/mgmt/rpc/server/CommBase.cc @@ -44,6 +44,9 @@ CommInternalErrorCategory::message(int ev) const return {"No more data to be read, but the buffer contains some invalid? data."}; case rpc::comm::InternalError::FULL_BUFFER: return {"Buffer's full."}; + case rpc::comm::InternalError::INVALID_SOCKET_PATH: + return {"Invalid RPC socket path: the path is either empty or exceeds the maximum length supported by the operating system. " + "Check the value of rpc.unix.sock_path_name in the configuration file."}; default: return "Internal Communication Error" + std::to_string(ev); } diff --git a/src/mgmt/rpc/server/IPCSocketServer.cc b/src/mgmt/rpc/server/IPCSocketServer.cc index 6791737e3da..c819c08fcac 100644 --- a/src/mgmt/rpc/server/IPCSocketServer.cc +++ b/src/mgmt/rpc/server/IPCSocketServer.cc @@ -139,15 +139,15 @@ IPCSocketServer::configure(YAML::Node const ¶ms) std::error_code IPCSocketServer::init() { + std::error_code ec; // Flag possible errors. // Need to run some validations on the pathname to avoid issue. Normally this would not be an issue, but some tests may fail on // this. if (_conf.sockPathName.empty() || _conf.sockPathName.size() > sizeof _serverAddr.sun_path) { - Dbg(dbg_ctl, "Invalid unix path name, check the size."); - return std::make_error_code(static_cast(ENAMETOOLONG)); + Dbg(dbg_ctl, "Invalid unix path name, check the size. Empty or too long."); + ec = InternalError::INVALID_SOCKET_PATH; + return ec; } - std::error_code ec; // Flag possible errors. - if (this->create_socket(ec); ec) { return ec; } diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc index 61982e77168..811539f1433 100644 --- a/src/traffic_server/traffic_server.cc +++ b/src/traffic_server/traffic_server.cc @@ -755,7 +755,7 @@ initialize_jsonrpc_server() // jsonrpcServer object. ink_assert(jsonrpcServer == nullptr); std::string msg; - return {false, swoc::bwprint(msg, "Server failed: '{}'", ex.what())}; + return {false, swoc::bwprint(msg, "Error: '{}'", ex.what())}; } // Register admin handlers. rpc::admin::register_admin_jsonrpc_handlers(); @@ -1995,7 +1995,10 @@ main(int /* argc ATS_UNUSED */, const char **argv) if (!command_flag) { // No need if we are going into command mode. // JSONRPC server and handlers if (auto &&[ok, msg] = initialize_jsonrpc_server(); !ok) { - Warning("JSONRPC server could not be started.\n Why?: '%s' ... Continuing without it.", msg.c_str()); + fprintf(stderr, + "[ERROR] JSONRPC server could not be started because: '%s', ATS will start without it, but traffic_ctl will not be " + "available.\n", + msg.c_str()); } }