From 595b628e0848b529cb6b84e07cc255ceeea62bb9 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 26 Aug 2025 14:00:36 -0400 Subject: [PATCH] Validate that the agent socket actually works If agent is 'kill -9', then recover from that by reaping the now dead socket. --- confluent_server/confluent/sshutil.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/confluent_server/confluent/sshutil.py b/confluent_server/confluent/sshutil.py index 83215abf..05fe3cc0 100644 --- a/confluent_server/confluent/sshutil.py +++ b/confluent_server/confluent/sshutil.py @@ -5,6 +5,7 @@ import confluent.config.configmanager as cfm import confluent.collective.manager as collective import confluent.util as util import eventlet.green.subprocess as subprocess +import eventlet.green.socket as socket import eventlet import glob import eventlet.green.os as os @@ -119,6 +120,15 @@ def prep_ssh_key(keyname): eventlet.sleep(0.1) adding_key = True if agent_pid: + if os.path.exists(os.environ['SSH_AUTH_SOCK']): + try: + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + sock.connect(os.environ['SSH_AUTH_SOCK']) + except Exception: + os.unlink(os.environ['SSH_AUTH_SOCK']) + os.rmdir(os.path.dirname(os.environ['SSH_AUTH_SOCK'])) + finally: + sock.close() if not os.path.exists(os.environ['SSH_AUTH_SOCK']): agent_pid = None ready_keys.clear()