Skip to content

Commit

Permalink
Use constent terminology - call them 'checks'
Browse files Browse the repository at this point in the history
  • Loading branch information
yrro committed Mar 13, 2024
1 parent 35a813a commit 9eaab1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/ipahealthcheck/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. ---"
)
Expand All @@ -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:
Expand All @@ -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),
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit 9eaab1f

Please sign in to comment.