Reverse logic of Healtchecks "skip_states" option to just "states" (#525).
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Dan Helfman 2022-05-24 14:09:42 -07:00
parent 865eff7d98
commit 8b179e4647
4 changed files with 12 additions and 12 deletions

4
NEWS
View File

@ -3,8 +3,8 @@
logs to send to the Healthchecks server.
* #402: Remove the error when "archive_name_format" is specified but a retention prefix isn't.
* #420: Warn when an unsupported variable is used in a hook command.
* #525: Add Healthchecks monitoring hook "skip_states" option to disable pinging for particular
monitoring states.
* #525: Add Healthchecks monitoring hook "states" option to only enable pinging for particular
monitoring states (start, finish, fail).
* #528: Improve the error message when a configuration override contains an invalid value.
* #531: BREAKING: When deep merging common configuration, merge colliding list values by appending
them. Previously, one list replaced the other.

View File

@ -901,7 +901,7 @@ properties:
send all logs and disable this truncation. Defaults
to 100000.
example: 200000
skip_states:
states:
type: array
items:
type: string
@ -911,9 +911,9 @@ properties:
- fail
uniqueItems: true
description: |
List of one or more monitoring states to skip
pinging for: "start", "finish", and/or "fail".
Defaults to pinging for all states.
List of one or more monitoring states to ping for:
"start", "finish", and/or "fail". Defaults to
pinging for all states.
description: |
Configuration for a monitoring integration with
Healthchecks. Create an account at https://healthchecks.io

View File

@ -98,9 +98,9 @@ def ping_monitor(hook_config, config_filename, state, monitoring_log_level, dry_
)
dry_run_label = ' (dry run; not actually pinging)' if dry_run else ''
if state.name.lower() in hook_config.get('skip_states', []):
if 'states' in hook_config and state.name.lower() not in hook_config['states']:
logger.info(
f'{config_filename}: Skipping Healthchecks {state.name.lower()} ping due to configured skip states'
f'{config_filename}: Skipping Healthchecks {state.name.lower()} ping due to configured states'
)
return

View File

@ -187,9 +187,9 @@ def test_ping_monitor_dry_run_does_not_hit_ping_url():
)
def test_ping_monitor_with_skip_states_does_not_hit_ping_url():
def test_ping_monitor_does_not_hit_ping_url_when_states_not_matching():
flexmock(module).should_receive('Forgetful_buffering_handler')
hook_config = {'ping_url': 'https://example.com', 'skip_states': ['start']}
hook_config = {'ping_url': 'https://example.com', 'states': ['finish']}
flexmock(module.requests).should_receive('post').never()
module.ping_monitor(
@ -201,9 +201,9 @@ def test_ping_monitor_with_skip_states_does_not_hit_ping_url():
)
def test_ping_monitor_hits_ping_url_with_non_matching_skip_states():
def test_ping_monitor_hits_ping_url_when_states_matching():
flexmock(module).should_receive('Forgetful_buffering_handler')
hook_config = {'ping_url': 'https://example.com', 'skip_states': ['finish']}
hook_config = {'ping_url': 'https://example.com', 'states': ['start', 'finish']}
flexmock(module.requests).should_receive('post').with_args(
'https://example.com/start', data=''.encode('utf-8')
)