Reverse logic of Healtchecks "skip_states" option to just "states" (#525).
This commit is contained in:
parent
865eff7d98
commit
8b179e4647
4 changed files with 12 additions and 12 deletions
4
NEWS
4
NEWS
|
@ -3,8 +3,8 @@
|
||||||
logs to send to the Healthchecks server.
|
logs to send to the Healthchecks server.
|
||||||
* #402: Remove the error when "archive_name_format" is specified but a retention prefix isn't.
|
* #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.
|
* #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
|
* #525: Add Healthchecks monitoring hook "states" option to only enable pinging for particular
|
||||||
monitoring states.
|
monitoring states (start, finish, fail).
|
||||||
* #528: Improve the error message when a configuration override contains an invalid value.
|
* #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
|
* #531: BREAKING: When deep merging common configuration, merge colliding list values by appending
|
||||||
them. Previously, one list replaced the other.
|
them. Previously, one list replaced the other.
|
||||||
|
|
|
@ -901,7 +901,7 @@ properties:
|
||||||
send all logs and disable this truncation. Defaults
|
send all logs and disable this truncation. Defaults
|
||||||
to 100000.
|
to 100000.
|
||||||
example: 200000
|
example: 200000
|
||||||
skip_states:
|
states:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
|
@ -911,9 +911,9 @@ properties:
|
||||||
- fail
|
- fail
|
||||||
uniqueItems: true
|
uniqueItems: true
|
||||||
description: |
|
description: |
|
||||||
List of one or more monitoring states to skip
|
List of one or more monitoring states to ping for:
|
||||||
pinging for: "start", "finish", and/or "fail".
|
"start", "finish", and/or "fail". Defaults to
|
||||||
Defaults to pinging for all states.
|
pinging for all states.
|
||||||
description: |
|
description: |
|
||||||
Configuration for a monitoring integration with
|
Configuration for a monitoring integration with
|
||||||
Healthchecks. Create an account at https://healthchecks.io
|
Healthchecks. Create an account at https://healthchecks.io
|
||||||
|
|
|
@ -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 ''
|
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(
|
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
|
return
|
||||||
|
|
||||||
|
|
|
@ -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')
|
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()
|
flexmock(module.requests).should_receive('post').never()
|
||||||
|
|
||||||
module.ping_monitor(
|
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')
|
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(
|
flexmock(module.requests).should_receive('post').with_args(
|
||||||
'https://example.com/start', data=''.encode('utf-8')
|
'https://example.com/start', data=''.encode('utf-8')
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue