From: Kamoltat Date: Tue, 1 Mar 2022 16:49:05 +0000 (+0000) Subject: task/internal: open gzip file if core is compressed X-Git-Tag: 1.2.0~144^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e65c680c629b7bf560d8082141ccd57e781497dd;p=teuthology.git task/internal: open gzip file if core is compressed Addded a case where if core is compressed, then we will try to open it as gzip and read the content inside. We also add try and except when we are parsing through the content to prevent the program from crashing. Fixes: https://tracker.ceph.com/issues/53206 Signed-off-by: Kamoltat Sirivadhna --- diff --git a/teuthology/task/internal/__init__.py b/teuthology/task/internal/__init__.py index d85b3f212..041964d38 100644 --- a/teuthology/task/internal/__init__.py +++ b/teuthology/task/internal/__init__.py @@ -12,6 +12,7 @@ import shutil import time import yaml import subprocess +import tempfile import humanfriendly @@ -318,7 +319,28 @@ def fetch_binaries_for_coredumps(path, remote): # 1422917770.7450.core: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, \ # from 'radosgw --rgw-socket-path /home/ubuntu/cephtest/apache/tmp.client.0/fastcgi_soc' log.info(f' core looks like: {dump_out}') - dump_program = dump_out.split("from '")[1].split(' ')[0] + + if 'gzip' in dump_out: + try: + log.info("core is compressed, try accessing gzip file ...") + with gzip.open(dump_path, 'rb') as f_in, \ + tempfile.NamedTemporaryFile(mode='w+b') as f_out: + shutil.copyfileobj(f_in, f_out) + dump_info = subprocess.Popen(['file', f_out.name], + stdout=subprocess.PIPE) + dump_out = dump_info.communicate()[0].decode() + log.info(f' core looks like: {dump_out}') + except Exception as e: + log.info('Something went wrong while opening the compressed file') + log.error(e) + continue + try: + dump_program = dump_out.split("from '")[1].split(' ')[0] + log.info(f' dump_program: {dump_program}') + except Exception as e: + log.info("core doesn't have the desired format, moving on ...") + log.error(e) + continue # Find path on remote server: remote_path = remote.sh(['which', dump_program]).rstrip()