Skip to content

Commit

Permalink
CA-390129: Handle & log exceptions in dump_xapi_rrds(hidden and disab…
Browse files Browse the repository at this point in the history
…led)

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
  • Loading branch information
bernhardkaindl committed Mar 21, 2024
1 parent bd7e5df commit 7b145fc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions xen-bugtool
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import traceback
import xml
import zipfile
from collections import OrderedDict
from contextlib import contextmanager
from hashlib import md5 as md5_new
from select import select
from signal import SIGHUP, SIGTERM, SIGUSR1
Expand Down Expand Up @@ -523,7 +524,16 @@ def no_unicode(x):
return x


def log_internal_error(e):
@contextmanager
def log_exceptions():
"""Context manager to log exceptions."""
try:
yield
except Exception as e: # pylint: disable=broad-except
log("%s, %s" % (e, traceback.format_exc()))


def log_internal_error(_):
"""Log an internal error and return an empty string as bugtool output data"""
log("bugtool: Internal error: " + traceback.format_exc())
return "" # For now, no diagnostic output in the individual output files
Expand Down Expand Up @@ -1134,7 +1144,8 @@ exclude those logs from the archive.
# tree_output(CAP_PAM, SAMBA_DATA_DIR) # Explictly skip samba data as it contains credentials
tree_output(CAP_PAM, VAR_LOG_DIR + "samba")

dump_xapi_rrds(entries)
with log_exceptions():
dump_xapi_rrds(entries)

cmd_output(CAP_PROCESS_LIST, [PS, 'wwwaxf', '-eo', 'pid,tty,stat,time,nice,psr,pcpu,pmem,nwchan,wchan:25,args'], label='process-tree')
func_output(CAP_PROCESS_LIST, 'fd_usage', fd_usage)
Expand Down

0 comments on commit 7b145fc

Please sign in to comment.