2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 17:43:14 +00:00

Support older python subprocess

Older python did not provide timeout.  Keep the timeout
for the modern python that skips select without a timeout,
but try again without timeout to retain compatibility.
This commit is contained in:
Jarrod Johnson 2021-10-20 18:23:35 -04:00
parent d441ff3d63
commit 40dea6a747
4 changed files with 24 additions and 7 deletions

View File

@ -15,7 +15,10 @@ def get_openssl_conf_location():
raise Exception("Cannot find openssl config file")
def get_ip_addresses():
lines = subprocess.check_output('ip addr'.split(' '), timeout=86400)
try:
lines = subprocess.check_output('ip addr'.split(' '), timeout=86400)
except TypeError:
lines = subprocess.check_output('ip addr'.split(' '))
if not isinstance(lines, str):
lines = lines.decode('utf8')
for line in lines.split('\n'):
@ -101,8 +104,12 @@ def assure_tls_ca():
if e.errno != 17:
raise
shutil.copy2('/etc/confluent/tls/cacert.pem', fname)
hv = subprocess.check_output(
['openssl', 'x509', '-in', '/etc/confluent/tls/cacert.pem', '-hash', '-noout'], timeout=86400)
try:
hv = subprocess.check_output(
['openssl', 'x509', '-in', '/etc/confluent/tls/cacert.pem', '-hash', '-noout'], timeout=86400)
except TypeError:
hv = subprocess.check_output(
['openssl', 'x509', '-in', '/etc/confluent/tls/cacert.pem', '-hash', '-noout'])
if not isinstance(hv, str):
hv = hv.decode('utf8')
hv = hv.strip()

View File

@ -217,7 +217,10 @@ def handle_request(env, start_response):
if ckeymap == 'n/a':
continue
keymap = ckeymap
tdc = subprocess.check_output(['timedatectl'], timeout=86400).split(b'\n')
try:
tdc = subprocess.check_output(['timedatectl'], timeout=86400).split(b'\n')
except TypeError:
tdc = subprocess.check_output(['timedatectl']).split(b'\n')
for ent in tdc:
ent = ent.strip()
if ent.startswith(b'Time zone:'):

View File

@ -43,7 +43,10 @@ def assure_agent():
if agent_pid is None:
try:
agent_starting = True
sai = subprocess.check_output(['ssh-agent'], timeout=86400)
try:
sai = subprocess.check_output(['ssh-agent'], timeout=86400)
except TypeError:
sai = subprocess.check_output(['ssh-agent'])
for line in sai.split(b'\n'):
if b';' not in line:
continue

View File

@ -142,8 +142,12 @@ def sync_list_to_node(sl, node, suffixes):
stage_ent(sl.appendoncemap, ent,
os.path.join(targdir, suffixes['appendonce']), True)
sshutil.prep_ssh_key('/etc/confluent/ssh/automation')
output = subprocess.check_output(
['rsync', '-rvLD', targdir + '/', 'root@{}:/'.format(node)], timeout=86400)
try:
output = subprocess.check_output(
['rsync', '-rvLD', targdir + '/', 'root@{}:/'.format(node)], timeout=86400)
except TypeError:
output = subprocess.check_output(
['rsync', '-rvLD', targdir + '/', 'root@{}:/'.format(node)])
except Exception as e:
if 'CalledProcessError' not in repr(e):
# https://github.com/eventlet/eventlet/issues/413