From 929392c74620299a9be8d73c4baeb27d455aba5b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 23 Sep 2021 10:42:47 -0400 Subject: [PATCH] Fix hangs on check_output Eventlet narrowly targets overriding select in subprocess, to avoid rewriting adequate functions. However, subprocess does an 'optimization' to skip select if there's fewer than 3 pipes to juggle and no timeout specified. Induce python to always use select by specifying a very long timeout. This causes confluent to be able to spawn multiple subprocesses and not be hung waiting for input. --- confluent_server/confluent/certutil.py | 4 ++-- confluent_server/confluent/selfservice.py | 4 ++-- confluent_server/confluent/syncfiles.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/certutil.py b/confluent_server/confluent/certutil.py index d5696d7a..a6119faa 100644 --- a/confluent_server/confluent/certutil.py +++ b/confluent_server/confluent/certutil.py @@ -15,7 +15,7 @@ def get_openssl_conf_location(): raise Exception("Cannot find openssl config file") def get_ip_addresses(): - lines = subprocess.check_output('ip addr'.split(' ')) + lines = subprocess.check_output('ip addr'.split(' '), timeout=86400) if not isinstance(lines, str): lines = lines.decode('utf8') for line in lines.split('\n'): @@ -102,7 +102,7 @@ def assure_tls_ca(): raise shutil.copy2('/etc/confluent/tls/cacert.pem', fname) hv = subprocess.check_output( - ['openssl', 'x509', '-in', '/etc/confluent/tls/cacert.pem', '-hash', '-noout']) + ['openssl', 'x509', '-in', '/etc/confluent/tls/cacert.pem', '-hash', '-noout'], timeout=86400) if not isinstance(hv, str): hv = hv.decode('utf8') hv = hv.strip() diff --git a/confluent_server/confluent/selfservice.py b/confluent_server/confluent/selfservice.py index 6e78dc0f..14e6ae5e 100644 --- a/confluent_server/confluent/selfservice.py +++ b/confluent_server/confluent/selfservice.py @@ -192,7 +192,7 @@ def handle_request(env, start_response): if needlocalectl: try: langinfo = subprocess.check_output( - ['localectl', 'status']).split(b'\n') + ['localectl', 'status'], timeout=86400).split(b'\n') except Exception: langinfo = [] for line in langinfo: @@ -216,7 +216,7 @@ def handle_request(env, start_response): if ckeymap == 'n/a': continue keymap = ckeymap - tdc = subprocess.check_output(['timedatectl']).split(b'\n') + tdc = subprocess.check_output(['timedatectl'], timeout=86400).split(b'\n') for ent in tdc: ent = ent.strip() if ent.startswith(b'Time zone:'): diff --git a/confluent_server/confluent/syncfiles.py b/confluent_server/confluent/syncfiles.py index 0449b55e..0bb6aa51 100644 --- a/confluent_server/confluent/syncfiles.py +++ b/confluent_server/confluent/syncfiles.py @@ -89,7 +89,7 @@ def sync_list_to_node(sl, node, suffixes): os.path.join(targdir, suffixes['merge']), True) sshutil.prep_ssh_key('/etc/confluent/ssh/automation') output = subprocess.check_output( - ['rsync', '-rvL', targdir + '/', 'root@{}:/'.format(node)]) + ['rsync', '-rvL', targdir + '/', 'root@{}:/'.format(node)], timeout=86400) finally: shutil.rmtree(targdir) return output