2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-04-10 01:44:51 +00:00

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.
This commit is contained in:
Jarrod Johnson 2021-09-23 10:42:47 -04:00
parent 5d20ee6cca
commit 929392c746
3 changed files with 5 additions and 5 deletions

View File

@ -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()

View File

@ -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:'):

View File

@ -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