]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/ceph_daemon: add 10s timeout to admin socket client 69833/head
authorNitzan Mordechai <nmordech@ibm.com>
Tue, 30 Jun 2026 10:42:42 +0000 (10:42 +0000)
committerNitzan Mordechai <nmordech@ibm.com>
Tue, 30 Jun 2026 10:46:02 +0000 (10:46 +0000)
ceph daemon command can hangs indefinitely when the target
daemon's admin socket is unresponsive. do_sockio() creates socket with
no timeout, so sock.recv(4) blocks forever if the daemon is slow to respond,
where AdminSocket::init() creates the socket file before store->mount()
returns).

The AdminSocketClient already uses a 10-second SO_RCVTIMEO / SO_SNDTIMEO.
Align the Python client by calling sock.settimeout(timeout) before connecting.
The default is 10s to match the C++ side; callers can pass timeout=None
to restore the previous blocking behaviour.

Fixes: https://tracker.ceph.com/issues/77743
Signed-off-by: Nitzan Mordechai <nmordech@ibm.com>
src/pybind/ceph_daemon.py

index b470eb1fdfac07da79a7af293482caa512e2477b..d2acf29cdbed06c40205132df6e4eed4e90c1dfe 100644 (file)
@@ -33,17 +33,21 @@ READ_CHUNK_SIZE = 4096
 
 def admin_socket(asok_path: str,
                  cmd: List[str],
-                 format: Optional[str] = '') -> bytes:
+                 format: Optional[str] = '',
+                 timeout: Optional[float] = 10) -> bytes:
     """
     Send a daemon (--admin-daemon) command 'cmd'.  asok_path is the
     path to the admin socket; cmd is a list of strings; format may be
     set to one of the formatted forms to get output in that form
     (daemon commands don't support 'plain' output).
+    timeout is the socket timeout in seconds (default 10, matching the
+    AdminSocketClient); pass None for no timeout (blocking forever).
     """
 
     def do_sockio(path: str, cmd_bytes: bytes) -> bytes:
         """ helper: do all the actual low-level stream I/O """
         sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        sock.settimeout(timeout)
         sock.connect(path)
         try:
             sock.sendall(cmd_bytes + b'\0')