This is an automated email from the ASF dual-hosted git repository.

dmeden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 95a50b6a11 fix(rpc): improve error reporting for socket path issues. 
(#12799)
95a50b6a11 is described below

commit 95a50b6a11f3a94685f50676c1db575d8a5e1961
Author: Damian Meden <[email protected]>
AuthorDate: Wed Jan 14 11:01:26 2026 +0100

    fix(rpc): improve error reporting for socket path issues. (#12799)
    
    * fix(rpc): improve error reporting for socket path issues.
    
    Replace generic ENAMETOOLONG errno with an error that indicates the rpc
    socket issue. Also improve startup error message clarity.
---
 include/mgmt/rpc/server/CommBase.h     | 2 +-
 src/mgmt/rpc/server/CommBase.cc        | 3 +++
 src/mgmt/rpc/server/IPCSocketServer.cc | 8 ++++----
 src/traffic_server/traffic_server.cc   | 7 +++++--
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/include/mgmt/rpc/server/CommBase.h 
b/include/mgmt/rpc/server/CommBase.h
index 76e90f9776..7dd0f89670 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 1bf7059264..41ecb1cecd 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 6791737e3d..c819c08fca 100644
--- a/src/mgmt/rpc/server/IPCSocketServer.cc
+++ b/src/mgmt/rpc/server/IPCSocketServer.cc
@@ -139,15 +139,15 @@ IPCSocketServer::configure(YAML::Node const &params)
 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<std::errc>(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 61982e7716..811539f143 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());
     }
   }
 

Reply via email to