diff --git a/src/ipahealthcheck/core/core.py b/src/ipahealthcheck/core/core.py index b68663a..829a717 100644 --- a/src/ipahealthcheck/core/core.py +++ b/src/ipahealthcheck/core/core.py @@ -55,13 +55,13 @@ def signal_handler(signum, frame): # plugin code, we also stash a copy of it so that we can log it after # the plugin returns. timed_out["exception"] = TimeoutError( - f"Health check {plugin_name} cancelled after {timeout} sec" + f"Check {plugin_name} cancelled after {timeout} sec" ) logger.error("--- %s ---", timed_out["exception"]) traceback.print_stack() timed_out["stack"] = traceback.format_stack() logger.error( - "--- The following messages were logged by the plugin after it" + "--- The following messages were logged by the check after it" " was cancelled. They may not indicate the reason why the plugin" " took too long to run. ---" ) @@ -71,6 +71,7 @@ def signal_handler(signum, frame): start = datetime.now(tz=timezone.utc) signal.signal(signal.SIGALRM, signal_handler) signal.alarm(timeout) + try: for result in plugin.check(): if result is None: @@ -90,7 +91,7 @@ def signal_handler(signum, frame): # result here based on the plugin's own exception, and _also_ # later on in the finally block. logger.exception( - "Exception raised in health check %r", + "Exception raised in check %r", plugin_name ) yield Result(plugin, constants.CRITICAL, exception=str(e), @@ -117,7 +118,7 @@ def signal_handler(signum, frame): traceback=timed_out["stack"]) else: logging.debug( - "Plugin %s complete after %s sec", + "--- Check %s complete after %s sec ---", plugin_name, datetime.now(tz=timezone.utc) - start ) signal.alarm(0) diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 5f4d44e..f7d7eb5 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -84,26 +84,26 @@ def check(self): assert 7 == len(results.results) - assert results.results[0].kw.get('exception') == 'Health check' \ + assert results.results[0].kw.get('exception') == 'Check' \ ' test_plugins:plugin_slow_passing_exception_up' \ ' cancelled after 1 sec' assert results.results[0].result == constants.ERROR assert results.results[0].kw.get('key') == 'healthcheck_timeout' - assert results.results[1].kw.get('exception') == 'Health check' \ + assert results.results[1].kw.get('exception') == 'Check' \ ' test_plugins:plugin_slow_catching_exception_and_ignoring' \ ' cancelled after 1 sec' assert results.results[1].result == constants.ERROR assert results.results[1].kw.get('key') == 'healthcheck_timeout' - assert results.results[2].kw.get('exception') == 'Health check' \ + assert results.results[2].kw.get('exception') == 'Check' \ ' test_plugins:plugin_slow_catching_exception_and_handling' \ ' cancelled after 1 sec' assert results.results[2].result == constants.ERROR assert results.results[2].kw.get('msg') == 'fail' assert results.results[2].kw.get('key') == 'test' - assert results.results[3].kw.get('exception') == 'Health check' \ + assert results.results[3].kw.get('exception') == 'Check' \ ' test_plugins:plugin_slow_catching_exception_and_handling' \ ' cancelled after 1 sec' assert results.results[3].result == constants.ERROR @@ -114,7 +114,7 @@ def check(self): assert results.results[4].result == constants.CRITICAL assert not results.results[4].kw.get('key') - assert results.results[5].kw.get('exception') == 'Health check' \ + assert results.results[5].kw.get('exception') == 'Check' \ ' test_plugins:plugin_slow_raising_exception cancelled after 1 sec' assert results.results[5].result == constants.ERROR assert results.results[5].kw.get('key') == 'healthcheck_timeout'