diff --git a/hotsos/cli.py b/hotsos/cli.py index 3debea7cd..1784d7fa5 100755 --- a/hotsos/cli.py +++ b/hotsos/cli.py @@ -257,45 +257,38 @@ def cli(data_root, version, defs_path, templates_path, all_logs, debug, host. """ # noqa - minimal_mode = None - if short: - minimal_mode = 'short' - elif very_short: - minimal_mode = 'very-short' - - HotSOSConfig.force_mode = force - repo_info = get_repo_info() - if repo_info: - HotSOSConfig.repo_info = repo_info - _version = get_version() - HotSOSConfig.hotsos_version = _version - HotSOSConfig.command_timeout = command_timeout - if version: print(_version) return - with DataRootManager(data_root, sos_unpack_dir=sos_unpack_dir) as drm: - if is_snap() and drm.data_root == '/': - print(SNAP_ERROR_MSG) - sys.exit(1) - - HotSOSConfig.set(use_all_logs=all_logs, plugin_yaml_defs=defs_path, - templates_path=templates_path, - data_root=drm.data_root, - event_tally_granularity=event_tally_granularity, - max_logrotate_depth=max_logrotate_depth, - max_parallel_tasks=max_parallel_tasks, - machine_readable=machine_readable) - - if debug and quiet: - sys.stderr.write('ERROR: cannot use both --debug and ' - '--quiet\n') - return - - HotSOSConfig.debug_mode = debug - with LoggingManager() as logmanager: + config = {'repo_info': get_repo_info(), + 'force_mode': force, + 'hotsos_version': _version, + 'command_timeout': command_timeout, + 'use_all_logs': all_logs, + 'plugin_yaml_defs': defs_path, + 'templates_path': templates_path, + 'event_tally_granularity': event_tally_granularity, + 'max_logrotate_depth': max_logrotate_depth, + 'max_parallel_tasks': max_parallel_tasks, + 'machine_readable': machine_readable, + 'debug_mode': debug} + HotSOSConfig.set(**config) + + with LoggingManager() as logmanager: + with DataRootManager(data_root, + sos_unpack_dir=sos_unpack_dir) as drm: + HotSOSConfig.data_root = drm.data_root + if is_snap() and drm.data_root == '/': + print(SNAP_ERROR_MSG) + sys.exit(1) + + if debug and quiet: + sys.stderr.write('ERROR: cannot use both --debug and ' + '--quiet\n') + return + # Set a name so that logs have this until real plugins are run. log.name = 'hotsos.cli' @@ -345,6 +338,13 @@ def cli(data_root, version, defs_path, templates_path, all_logs, debug, output_path=output_path) sys.stdout.write("INFO: output saved to {}\n".format(path)) else: + if short: + minimal_mode = 'short' + elif very_short: + minimal_mode = 'very-short' + else: + minimal_mode = None + out = summary.get(fmt=output_format, html_escape=html_escape, minimal_mode=minimal_mode) diff --git a/hotsos/core/root_manager.py b/hotsos/core/root_manager.py index 7061f44e8..6a859df4f 100644 --- a/hotsos/core/root_manager.py +++ b/hotsos/core/root_manager.py @@ -7,6 +7,7 @@ from hotsos.core.config import HotSOSConfig from hotsos.core.host_helpers import CLIHelper +from hotsos.core.log import log class DataRootManager(object): @@ -75,6 +76,8 @@ def data_root(self): try: tar.extractall(self.tmpdir) except Exception: + log.exception("error occured while unpacking " + "sosreport:") # some members might fail to extract e.g. permission # denied but we dont want that to cause the whole run # to fail so we just log a message and ignore them.